Skip Menu |

This queue is for tickets about the DBD-DB2 CPAN distribution.

Report information
The Basics
Id: 59026
Status: resolved
Priority: 0/
Queue: DBD-DB2

People
Owner: Nobody in particular
Requestors: morten.bjornsvik [...] experian-da.no
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: <morten_bjoernsvik [...] yahoo.no>
Subject: DBD::DB2 v1.78 'current timestamp binding failure
Date: Thu, 1 Jul 2010 16:55:56 +0200
To: <bug-DBD-DB2 [...] rt.cpan.org>
From: Morten Bjørnsvik <morten.bjornsvik [...] experian-da.no>
Hi I have problems binding 'current timestamp', I'm not sure if this is a bug or user-error, This has been working previously, but I deleted some tables, and then it did not worked. # this does not work $sth->bind_param( 2, 'current timestamp', DBI::SQL_DATETIME ); # this works $sth->bind_param( 2, '2010-07-01 10:00:00', DBI::SQL_DATETIME ); db2inst1@mortenb2:~> db2ls Install Path Level Fix Pack Special Install Number Install Date Installer UID --------------------------------------------------------------------------------------------------------------------- /opt/ibm/db2/V9.5 9.5.0.0 0 Tue Sep 16 09:54:35 2008 CEST 0 Install Path Level Fix Pack Special Install Number Install Date Installer UID --------------------------------------------------------------------------------------------------------------------- /opt/ibm/db2/V9.5 9.5.0.4 4 Wed Jun 24 09:40:12 2009 CEST 0 Test program: mbj@mortenb2:~/perl> ./test-dbdbinding.pl DBD::DB2::VERSION:1.78 plain insertion ok DBD::DB2::st execute failed: [IBM][CLI Driver] CLI0113E SQLSTATE 22007: An invalid datetime format was detected; that is, an invalid string representation or value was specified. SQLSTATE=22007 at ./test-dbdbinding.pl line 45. got error: -99999 got error: [IBM][CLI Driver] CLI0113E SQLSTATE 22007: An invalid datetime format was detected; that is, an invalid string representation or value was specified. SQLSTATE=22007 due to error at ./test-dbdbinding.pl line 53. #!/opt/perl/bin/perl -w use Data::Dumper; use DBI; require DBD::DB2; my $connect_hash = { dbi => 'DBI:DB2:psecana', user => 'db2inst2', pw => 'start1' }; print "DBD::DB2::VERSION:" . $DBD::DB2::VERSION . "\n"; my $dbh = DBI->connect( $connect_hash->{dbi}, $connect_hash->{user}, $connect_hash->{pw} ); if(! defined $dbh) { die("error unable to connect using " . Dumper($connect_hash)); } # standard insert my $sql = "insert into nodehost (host,time,master,refresh,status) values('192.168.2.31:5555',current timestamp,1,current timestamp,'ok')"; my $sth = $dbh->prepare( $sql ); $sth->execute(); if( defined $dbh->err() || defined $sth->errstr() ) { if( defined $dbh->err() ) { print "got error: " . $dbh->err() . "\n"; } if(defined $sth->errstr()) { print "got error: " . $sth->errstr() . "\n"; } die("due to error"); } else { print "plain insertion ok\n"; } # bind insert: $sql = "insert into nodehost (host,time,master,refresh,status) values(?,?,?,?,?)"; $sth = $dbh->prepare( $sql ); $sth->bind_param( 1, '192.168.2.32:5555', DBI::SQL_VARCHAR ); $sth->bind_param( 2, 'current timestamp', DBI::SQL_DATETIME ); #$sth->bind_param( 2, '2010-07-01 10:00:00', DBI::SQL_DATETIME ); $sth->bind_param( 3, 0, DBI::SQL_INTEGER ); $sth->bind_param( 4, 'current timestamp', DBI::SQL_DATETIME ); #$sth->bind_param( 4, '2010-07-01 10:00:00', DBI::SQL_DATETIME ); $sth->bind_param( 5, 'ok', DBI::SQL_VARCHAR ); $sth->execute(); if( defined $dbh->err() || defined $sth->errstr() ) { if( defined $dbh->err() ) { print "got error: " . $dbh->err() . "\n"; } if(defined $sth->errstr()) { print "got error: " . $sth->errstr() . "\n"; } die("due to error"); } else { print "bind insertion is ok\n"; } $sth->finish(); $dbh->disconnect(); =pod db2inst1@mortenb2:~> db2 "describe table nodehost" Data type Column Column name schema Data type name Length Scale Nulls ------------------------------- --------- ------------------- ---------- ----- ------ HOST SYSIBM VARCHAR 20 0 No TIME SYSIBM TIMESTAMP 10 0 No MASTER SYSIBM INTEGER 4 0 Yes REFRESH SYSIBM TIMESTAMP 10 0 No STATUS SYSIBM VARCHAR 20 0 Yes 5 record(s) selected. =cut ---------------------------------------------------------------- Morten Bjørnsvik, Experian Decision Analytics AS Sørkedalsveien 10c, Postbox 5275 Majorstua, 0303 Oslo, Norway Mob: +47 92 44 83 02, Dir: +47 21 52 12 65, Fax: +47 21 52 12 51 ----------------------------------------------------------------
Subject: RE: [rt.cpan.org #59026] DBD::DB2 v1.78 'current timestamp binding failure
Date: Thu, 1 Jul 2010 22:39:18 +0200
To: <bug-DBD-DB2 [...] rt.cpan.org>
From: Morten Bjørnsvik <morten.bjornsvik [...] experian-da.no>
Hi I found myself a workaround using: my $sql = "insert into nodehost (host,time,master,refresh,status)" . " values(?,current timestamp,?,current timestamp,?); and just omitting the 2 bind_params regarding 'current timstamp'. I also tried replacing the 'current timestamp' ? with: ? => cast(? as timestamp), but it did not work either. I'm pretty sure this has worked earlier, since the particular code has been running for months. The drawback of not having ? is our sth cache which will make separate entries for all the ? and 'current timestamp' variations. -- MortenB
Hi Morten, This is working as expected. CURRENT TIMESTAMP is a register value on the server side and hence works fine when issuing a plane SQL, however when you try to bind, the data is first checked at the client side and hence error invalid representation when the string 'CURRENT TIMESTAMP' is seen. Could you let me know of the previous configuration (Client and server version, DBD::DB2 version) where it was working. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)
Closing the defect, as no activity seen. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)