Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Bind parameters for SET statements

Posted on 2011-03-03 01:25:03 by Alfie John

Hi,

Not sure if this is a DBD::mysql or a plain DBI problem but thought I
would start here.

It seems that the following code is broken:

$dbh->do( 'SET TIMESTAMP=?', undef, $timestamp );

This fails with:

Incorrect argument type to variable 'timestamp'

Yet the following works:

$dbh->do( "SET TIMESTAMP=$timestamp" );

Alfie

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Report this message

#2: Re: Bind parameters for SET statements

Posted on 2011-03-03 02:10:26 by Alfie John

On Thu, Mar 03, 2011 at 11:25:03AM +1100, Alfie John wrote:
> It seems that the following code is broken:
>
> $dbh->do( 'SET TIMESTAMP=?', undef, $timestamp );
>
> This fails with:
>
> Incorrect argument type to variable 'timestamp'

On further investigation, we've found that DBI is sending the timestamp
over the wire as a string hence the incorrect argument type.

Although not ideal, We have the following work arounds:

$dbh->do( "SET TIMESTAMP=cast( ? AS UNSIGNED INTEGER )", undef, $timestamp );

And

use DBI qw{ :sql_types };
...
my $sth = $dbh->prepare( "SET TIMESTAMP=?" );
$sth->bind_param( 1, $timestamp, { TYPE => SQL_INTEGER } );
$sth->execute();

Alfie

>
> Yet the following works:
>
> $dbh->do( "SET TIMESTAMP=$timestamp" );
>
> Alfie
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=alfie@h4c.kr
>

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Report this message