X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id BC62C30E51B for ; Wed, 18 Jun 2003 19:28:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 11014-04 for ; Wed, 18 Jun 2003 16:28:27 -0300 (ADT) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id E134830E3E9 for ; Wed, 18 Jun 2003 16:28:26 -0300 (ADT) Received: (qmail 30373 invoked by uid 505); 18 Jun 2003 19:28:29 -0000 Received: from mallah@trade-india.com by ns1.trade-india.com by uid 502 with qmail-scanner-1.16 (clamscan: 0.54. spamassassin: 2.54. Clear:SA:0(-100.1/5.0):. Processed in 0.561789 secs); 18 Jun 2003 19:28:29 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 18 Jun 2003 19:28:28 -0000 Received: from 219.65.233.126 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 19 Jun 2003 00:58:28 +0530 (IST) Message-ID: <1205.219.65.233.126.1055964508.squirrel@mail.trade-india.com> Date: Thu, 19 Jun 2003 00:58:28 +0530 (IST) Subject: Re: Perl DBI question From: To: In-Reply-To: References: <480641561E05E94D9B6CCE1E39AA0300116792@PDAWB06C.ad.sprint.com> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200306/244 X-Sequence-Number: 9235 setting RaiseError to true is the way to go in DBI. it catches most of the error and prints in apache error log. if RaiseError = 1 one does not have to do the explicit die after the connect even i think regds mallah, > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > You should not be using the "do" method, but the prepare/execute model instead. Using > placeholders can not only be more efficient but allows quoting to happen properly. Here is a > rewrite: > > #--Establish the DB connection > #--Assign the DB name > my $dbName = 'checkbook'; > my $dbuser = "joe"; > my $dbpass = "sixpak"; > > my $dbh = DBI->connect("dbi:Pg:dbname=$dbName", $dbuser, $dbpass, {AutoCommit=>1, > RaiseError=>1}) > or die "Could not connect to the database: $DBI::errstr\n"; > > my $SQL = " > INSERT INTO transactions (date,description,amount,confirmation,nameid,typeid) VALUES > (? ,? ,? ,? ,? ,? )"; > > my $sth = $dbh->prepare($SQL); > > my $count = $sth->execute($datePaid,$description,$amount, $confirmation,$nameid,$typeid); > > print "Insert count: $count\n"; > > > It is hard to tell why your inserts are going wrong without more information, but the > RaiseError should at least help catch some obvious errors. > > > - -- > Greg Sabino Mullane greg@turnstep.com > PGP Key: 0x14964AC8 200306181337 > > -----BEGIN PGP SIGNATURE----- > Comment: http://www.turnstep.com/pgp.html > > iD8DBQE+8KUHvJuQZxSWSsgRAhWoAJ9/aw9AaCMa5vGvEpvujEEBm4iBXQCggSSw > jPaGcdMt9Qq9XeJqttvdX48= > =x1nu > -----END PGP SIGNATURE----- > > > > ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to > increase your free space map settings ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/