From: | <mallah(at)trade-india(dot)com> |
---|---|
To: | <greg(at)turnstep(dot)com> |
Cc: | <pgsql-admin(at)postgresql(dot)org>, <mkoval01(at)sprintspectrum(dot)com> |
Subject: | Re: Perl DBI question |
Date: | 2003-06-18 19:28:28 |
Message-ID: | 1205.219.65.233.126.1055964508.squirrel@mail.trade-india.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
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(at)turnstep(dot)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/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-06-18 21:28:38 | Re: postgreSQL 7.3.3 crashing on server with Itanium processor... |
Previous Message | matt | 2003-06-18 19:27:12 | Re: PostgreSQL calibration |