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 848BF30DF8C for ; Wed, 18 Jun 2003 17:48:41 +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 95218-09 for ; Wed, 18 Jun 2003 14:48:06 -0300 (ADT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id 61E5830DEC3 for ; Wed, 18 Jun 2003 14:48:00 -0300 (ADT) Received: (qmail 20575 invoked from network); 18 Jun 2003 17:47:59 -0000 Received: from biglumber.com (HELO localhost) (207.228.252.42) by 0 with SMTP; 18 Jun 2003 17:47:59 -0000 From: greg@turnstep.com To: pgsql-admin@postgresql.org Cc: mkoval01@sprintspectrum.com Cc: mkoval01@sprintspectrum.com Subject: Re: Perl DBI question X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <480641561E05E94D9B6CCE1E39AA0300116792@PDAWB06C.ad.sprint.com> Date: Wed, 18 Jun 2003 17:47:59 -0000 X-Mailer: JoyMail 1.37 Message-ID: X-Archive-Number: 200306/241 X-Sequence-Number: 9232 -----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-----