in reply to PostgreSQL UPDATE

I can't believe the response time in this place. I love it. BTW, My insert statment works fine so i did not include that script. I tried to compare the two but nothing seemed wrong there.
########################################## ## Create a connection to the database. ## ########################################## sub Create_DB_Connection{ use DBI; use DBD::Pg; $DSN = "DBI:Pg:dbname=blah"; $user = "blah"; $pw = "blah"; $dbh = DBI->connect($DSN,$user,$pw) || die "Cannot connect: $DBI::errstr\n" unless $dbh; return; } # End of Create_DB_Connection subroutine. ########################################## ########################################## ## Executes the SQL command and then ## ## returns to the calling area of the ## ## program. ## ########################################## sub Do_SQL{ eval{ $sth = $dbh->prepare($SQL); }; # End of eval # Check for errors. if($@){ $dbh->disconnect; print "Content-type: text/html\n\n"; print "An ERROR occurred! $@\n<P>"; exit; } else { $sth->execute; } # End of if..else return ($sth); } # End of Do_SQL subroutine #################################################################

Replies are listed 'Best First'.
Re: Re: PostgreSQL UPDATE
by chromatic (Archbishop) on Jul 18, 2001 at 23:20 UTC
    Your eval won't catch anything unless you set the RaiseError attribute on your database handle:
    $dbh = DBI->connect($DSN,$user,$pw, { RaiseError => 1 }) || die "Cannot connect: $DBI::errstr\n" unless $dbh;
    Otherwise, check the results of all of your $dbh calls for undef and do something with $DBI::errstr yourself.
      This is also where you can set AutoCommit, by the way.

      adamsj

      They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen

Re: Re: PostgreSQL UPDATE
by nlafferty (Scribe) on Jul 18, 2001 at 22:55 UTC
    Forgot the filter code. All three of these are contained in common.sub
    #################################### ### Filter - Gets rid of ### ### characters that screw up the ### ### program. ### #################################### sub filter{ $_[0]=~s/\'/\\\'/g; return $_[0]; } # End of filter subroutine ################################################################# 1; # Required or won't work!