Bill,
        Reverse the order of the bind_params and see if it fails on mysql
        now ;-)

        > $td_sth->bind_param(1,my $line) ;
        > $td_sth2->bind_param(1,my $line) ;
        
        When you later use $line, which my $line is referred to?  The first
        bind_param (the Pg) never receives a value because of the second my
        $line.

        use strict;

        use warnings;


my $line;
        $line = 'A';

my $line;

print $line, "\n";

[tlowery@stllnx1 tlowery]$ perl -w fred.pl
"my" variable $line masks earlier declaration in same
scope at fred.pl line 11.
Use of uninitialized value in print at fred.pl line 13.

use warnings and -w are your friend.

Tom


On Sun, Jun 09, 2002 at 06:54:07PM -0400, Bill Kurland wrote:
> Is there something broken with parameter binding in DBD::Pg or am I just 
> missing something? Code
> that worked fine with mysql is broken when run against a postgreSQL 
> database. I pulled out the
> relevant code and ran it against both DBMS's - works fine in mysql, but 
> gives an error against postgreSQL :
> 
> ERROR:  ExecAppend: Fail to add null value in not null attribute line_no
> 
> Any help is greatly appreciated. Thanks
> 
> use DBI ;
> use strict;
> 
> my($dsn) = "DBI:Pg:dbname=bbreg;host='host'" ;
> 
> my $bbreg_h = DBI->connect($dsn,'username','password', {
>       PrintError => 0,
>       RaiseError => 0
> })  ;
> unless($bbreg_h){
>       print "\a\a\a" ;
>       print DBI->errstr . "\tError Number:" . DBI->err ;
>       exit;
> }
> 
> my($dsn2) = "DBI:mysql:bbreg:host2";
> 
> my $bbreg2_h = DBI->connect($dsn2,'username','password' , {
>               PrintError => 0,
>               RaiseError => 0
>       })  ;
> 
> my $td_sth = $bbreg_h->prepare( "
>       INSERT INTO trans_dtl
>       (cashier, store, tran_no, line_no, loc, isbn, author, title, price, 
> course_no, term, retail       )
>       VALUES ('username', 5, 1,?, ?, ?, ?, ? , ? , ? , ? , ?)
>       ");
> 
> $td_sth->bind_param(1,my $line) ;
> $td_sth->bind_param(2,my $where) ;
> $td_sth->bind_param(3,my $isbn) ;
> $td_sth->bind_param(4,my $author) ;
> $td_sth->bind_param(5,my $title) ;
> $td_sth->bind_param(6,my $price) ;
> $td_sth->bind_param(7,my $course_no) ;
> $td_sth->bind_param(8,my $term) ;
> $td_sth->bind_param(9,my $retail) ;
> 
> my $td_sth2 = $bbreg2_h->prepare( "
>       INSERT INTO trans_dtl
>       (cashier, store, tran_no, line_no, loc, isbn, author, title, price, 
> course_no, term, retail       )
>       VALUES ('username', 5, 1,?, ?, ?, ?, ? , ? , ? , ? , ?)
>       ");
> 
> $td_sth2->bind_param(1,my $line) ;
> $td_sth2->bind_param(2,my $where) ;
> $td_sth2->bind_param(3,my $isbn) ;
> $td_sth2->bind_param(4,my $author) ;
> $td_sth2->bind_param(5,my $title) ;
> $td_sth2->bind_param(6,my $price) ;
> $td_sth2->bind_param(7,my $course_no) ;
> $td_sth2->bind_param(8,my $term) ;
> $td_sth2->bind_param(9,my $retail) ;
> 
> my @prompts = qw( Location:  ISBN:  Author: Title: Price: Course: Term: 
> Retail:) ;
> my @history ;
> my $cnt = 0;
> my $max = shift ;
> 
> while(){
>       my @line ;
>       push @line, ($cnt) ;
>       foreach my $prompt (@prompts){
>               print "Enter " . $prompt ;
>               while(<>){
>                       chomp ;
>                       print "$_\n";
>                       push @line, ($_) ;
>                       last;
>               }
>       }
>       unshift @history, \@line ;
>       $cnt++ ;
>       last if  $cnt > $max  ;
> }
> 
> foreach my $line_no (@history){
>       ($line,$where,$isbn,$author,$title,$price,$course_no,$term,$retail) = 
> @$line_no ;
>       print   join ':', 
> ($line,$where,$isbn,$author,$title,$price,$course_no,$term,$retail), 
> "\n" ;
>       $td_sth->execute() or  warn DBI->errstr(), "\n";
>       $td_sth2->execute() or  warn DBI->errstr(), "\n";
> }
> $bbreg_h->disconnect() ;
> $bbreg2_h->disconnect() ;
> 
> The client is running under  Windows NT.
> Active State Perl version 5.6.0 built for MSWin32-x86-multi-thread
> DBI      v1.23
> DBD::Pg v0.95
> DBD::mysql   1.2200
> 
> According to ppm, these are the latest available versions.

-- 
Thomas A. Lowery
See DBI/FAQ http://xmlproj.dyndns.org/cgi-bin/fom

Reply via email to