Hi,

I wonder!.
Why does my insert depends of the column order??
 
Do any have any explanation?? 

In table t3, tt is text, and date is datetime.

I try to insert the following line:
"change the '/' to '\' and the 'rm' to 'del' and am trying" 
(replaced with a teststring)
and a time stamp,
but the backslash in the quotes are kidding.

It gives the following error:
DBD::Pg::db do failed: ERROR:  Bad timestamp external 
representation '2000-10-30 21NULLNULL' at 1 line 29.
Can't do select: ERROR:  Bad timestamp external representation 
'2000-10-30 21NULLNULL'
insert into t3 (tt, date) 
values ( 'AKKKKaaaaa ''\\'' bbbbbbbb', '2000-10-30 21:10:05')
1 at 1 line 29.                                                                


If I change the column order in the insert then the insert is ok.

#insert using the do method
--------------------------------------------------------------------
use DBI;

# PG connection
$conn_pg = "DBI:Pg:dbname=test;host=localhost";
$uid_pg="postgres_user";
$pwd_pg="postgres_pw";
$dbh_pg = DBI->connect( "$conn_pg", "$uid_pg", "$pwd_pg" );

 $val="AKKKKaaaaa '\\' bbbbbbbb";
 $date="2000-10-30 21:10:05";

        # Quote the data
        $val_q  = $dbh_pg->quote( $val, TEXT);
        $date_q  = $dbh_pg->quote( $date, DATETIME);



        # This sql insert fails
        $SqlCode_pg = "insert into t3 (tt, date) values ( $val_q, $date_q)";

        # This sql insert is ok, I have only changed the column order.
        #$SqlCode_pg = "insert into t3 (date, tt) values ( $date_q, $val_q)";




        $sth_pg = $dbh_pg->do("$SqlCode_pg")
        or
        die print "Can't do select: $DBI::errstr\n$SqlCode_pg\n";

warn $DBI::errstr if $DBI::err;

$rcdb1_pg = $dbh_pg->disconnect;                 
                                  
                                             
--------------------------------------------------------------------
perl -v

This is perl, v5.6.1 built for i686-linux

Copyright 1987-2001, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.    
-----------------------------------------------------------
DBI:Pg version 1.01

>From the psql commandline interface there is no problem.

/kk

Reply via email to