How to track the success of insert

From: Anish Kumar K. (anish_at_vitalect-india.com)
Date: 09/29/04


To: "beginners perl" <beginners@perl.org>
Date: Wed, 29 Sep 2004 12:58:13 +0530

Hi

I was trying out some practice examples with DBI and CGI and kind of stuck while doing a comparison

That is if I could insert successfully into a databse a script window shld come "Success". but when the insert fails
a window shld come saying "Can;t insert "..

How will I track if the insertion is success or not? Below is the program...

use strict;
use warnings;
use CGI;
use DBI;
my $cgi = new CGI;
print $cgi->header( "text/html" );
print $cgi->start_html( "Welcome" );
my $dbh = DBI->connect("DBI:Pg:dbname=testdb;host=localhost",'postgres','postgres',{RaiseError=>1,PrintErr
or=>1})
or die "Cannot connect to testdb\n";

my $sth=$dbh->prepare("insert into userinfo values('$fvalue','$lvalue','$email')");
$sth->execute();
   if($sth)
    {
       print $cgi->p( "<script language=Javascript> alert('Execution Done') </script>" );
    }
 else
   {
       print $cgi->p("<Script language=Javascript> alert('Execution Not Done') </script>" );
   }



Relevant Pages

  • RE: How to track the success of insert
    ... > How will I track if the insertion is success or not? ... > use CGI; ... > use DBI; ... Put your instert inside a transaction like this: ...
    (perl.beginners)
  • RE: How to track the success of insert
    ... > How will I track if the insertion is success or not? ... > use CGI; ... > use DBI; ... Put your instert inside a transaction like this: ...
    (perl.beginners)
  • Re: IIS 6.0 CGI pipe broken...
    ... when I run the CGI as IUSR in the command line (with success), ... First the CGI reads 23 times its .ini file, ... (the pipe of the database client app) ...
    (microsoft.public.inetserver.iis.security)
  • Re: IIS 6.0 CGI pipe broken...
    ... Besides, the CGI uses the ... file access made by the CGI is to the INI file to read the error string... ... a UNC server/share name, so it chokes on a server named "?"). ... If I remove \\?\ I see success and connect to ...
    (microsoft.public.inetserver.iis.security)
  • Re: IIS 6.0 CGI pipe broken...
    ... > the CGI not running, but I do not know why. ... > able to read the INI file; it doesn't seem to like the name of the CGI ... If I remove \\?\ I see success and connect to ... Hoch. ...
    (microsoft.public.inetserver.iis.security)