pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: boyd <tbmoore@bealenet.com>
To: pgsql-sql@postgresql.org
Subject: Re: Different query results in psql and Perl DBI with Postgres 7.2.1
Date: Thu, 08 Jan 2004 07:05:10 -0500
Message-ID: <tbmoore-BAFC5F.07051008012004@news.ispnews.com> (raw)
References: <cf7bc53b.0401070314.41bc05ad@posting.google.com>

In article <cf7bc53b.0401070314.41bc05ad@posting.google.com>,
 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




view thread (3+ messages)  latest in thread

Message-ID: <tbmoore-BAFC5F.07051008012004@news.ispnews.com>
Permalink:  ../tbmoore-BAFC5F.07051008012004@news.ispnews.com/
Also on:    postgresql.org/message-id/tbmoore-BAFC5F.07051008012004@news.ispnews.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tbmoore@bealenet.com
  Subject: Re: Different query results in psql and Perl DBI with Postgres 7.2.1
  In-Reply-To: <tbmoore-BAFC5F.07051008012004@news.ispnews.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox