[Sqlrelay-discussion] SQLRelay, bind_params and DB2
Brought to you by:
mused
|
From: Lawrence, G. <gla...@uc...> - 2009-03-30 21:12:17
|
Howdy,
I'm testing out sql relay with a db2 install. I'm doing about the lamest bit of code possible just to make sure it's all going to work.
Code here:
#!/usr/bin/env perl
use DBI;
my $dbh=DBI->connect("DBI:SQLRelay:host=localhost;port=9000;socket=;"," XXXXXXXXXXXX","XXXXXXXXXXXX");
my $sth=$dbh->prepare("select * from db2actq.zip_codes where state = ?");
$sth->bind_param(1,"CA");
$sth->execute();
while (@data=$sth->fetchrow_array()) {
foreach $col (@data) {
print "\"$col\",";
}
print "\n";
}
$dbh->disconnect;
And I get an error result:
DBD::SQLRelay::st execute failed: [IBM][CLI Driver][DB2/SUN] SQL0312N The host variable "1" is used in a dynamic SQL statement, a view definition, or a trigger definition. SQLSTATE=42618
Which seems obvious enough... but, and documentation for SQL0312N has a simple enough resolution:
Use parameter markers (?) instead of host variables for dynamic SQL statements. Do not use host variables and parameter markers in view or trigger definitions.
Except... that's what I thought I was doing... Am I missing something?
Thanks,
Gabe
------------------------------------
Gabriel Lawrence
Director, IT Security
UC San Diego
|