X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DD5B8D1B469 for ; Thu, 8 Jan 2004 12:35:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44258-04 for ; Thu, 8 Jan 2004 08:35:03 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 08C6FD1B438 for ; Thu, 8 Jan 2004 08:35:00 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i08CYxU6096931 for ; Thu, 8 Jan 2004 12:34:59 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i08C5FCR080361 for pgsql-sql@postgresql.org; Thu, 8 Jan 2004 12:05:15 GMT From: boyd X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Different query results in psql and Perl DBI with Postgres 7.2.1 References: User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: Lines: 72 X-Complaints-To: abuse@usenetserver.com X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly. Date: Thu, 08 Jan 2004 07:05:10 -0500 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/54 X-Sequence-Number: 16447 In article , brendanl@iname.com (Brendan LeFebvre) wrote: > I have a script that updates one record in a PostgreSQL 7.2.1 database > through the Perl DBI. > > Where do I even begin to attempt a diagnosis? Here is the output from a script I ran with no problems under 7.2.1, followed by the script: OUTPUT --------- DB info : PostgreSQL 7.2.1 Table "item" Column | Type | Modifiers ---------+---------+----------- item_id | integer | status | text | doing query < TRUNCATE item > -1 rows affected doing query < INSERT INTO item VALUES(1129832,'BACKORDER') > 1 rows affected doing query < INSERT INTO item VALUES(1130081,'OUTOFSTOCK') > 1 rows affected doing query < UPDATE item SET status='SOLD' WHERE item_id=1129832 > 1 rows affected doing query < UPDATE item SET status='STORE' WHERE item_id=1130081 > 1 rows affected SCRIPT ------ #!/usr/bin/perl -w use strict; use DBI; our $DBH; sub dienicely { warn "$DBH->errstr"; $DBH->disconnect; } sub runquery { my $sql = shift; print "doing query < $sql > \n"; my $rows = $DBH->do($sql) or dienicely; print "$rows rows affected\n"; } $DBH = DBI->connect("dbi:Pg:dbname=boyd","",""); my $info = $DBH->get_info(17) .' '. $DBH->get_info(18); $info =~ s/0//g; # the get_info adds extraneous '0' to the version number print "DB info : $info\n"; print `psql -c '\\d item'`; runquery("TRUNCATE item"); runquery( "INSERT INTO item VALUES(1129832,'BACKORDER')" ); runquery( "INSERT INTO item VALUES(1130081,'OUTOFSTOCK')" ); runquery( "UPDATE item SET status='SOLD' WHERE item_id=1129832" ); runquery( "UPDATE item SET status='STORE' WHERE item_id=1130081" ); $DBH->disconnect; Hope that helps. Boyd