#!/usr/local/bin/perl use CGI; use DBI; # Make up a pulldown menu of all known patients $db_handle = DBI -> connect("DBI:Pg:dbname=northwind; host=localhost", "postgres", "postgres", {'RaiseError' => 1}); $query = "SELECT \"EmployeeID\" AS empid, \"FirstName\"::text || ' ' ||\"LastName\"::text AS name FROM \"Employees\""; $db_handle->do("SET search_path to northwind") or die; $qh = $db_handle->prepare($query); $qh->execute; while (@row = $qh->fetchrow) { $hh .= "\n"; } # Send out the header and form print "content-type: text/html\n\n"; print <<"HEADER"; Delete an employee record

Delete an employee

Select Employee name to delete :

HEADER # Read information from the form read(STDIN,$buffer,$ENV{CONTENT_LENGTH}); @pairs = split(/&/,$buffer); foreach (@pairs) { ($n,$v) = split(/=/); $v =~ tr/+/ / ; $v =~ s/%(..)/pack("C",hex($1))/ge; $input{$n} = $v; } # If the form was properly submitted, save the data if ($input{"go"} eq "DELETE") { $query = "DELETE FROM \"Employees\" WHERE \"EmployeeID\"="." \'$input{empid}\'"; $db_handle -> do($query); $action = "Record saved - $query"; # If the form has not been submitted, ask for data } else { $action = "Please complete form"; } # Standard links to the rest of the application print <<"FOOTER"; $action
Jump to - View Employees Listing
Jump to - Add an Employee
Jump to - Add or update Employee Photo

Edited by Terry on July, 06 2014. FOOTER