Re: Trouble with parameters and IN query
Oh, nuts. This always happens. After wrestling with the problem for hours, I post on a forum for help then immediately figure out the solution myself!
I almost had it right with this:
my $user_supplied_value = '2,3';
$sth = $dbh->prepare(qq( select * from ip where id in (?) ));
$sth->bind_param(1, $user_supplied_value, { TYPE => 'SQL_INTEGER' });
$sth->execute() or print $sth->errstr, "<br>\n";
What I was actually supposed to do was this:
use DBI qw(:sql_types);
my $user_supplied_value = '2,3';
$sth = $dbh->prepare(qq( select * from ip where id in (?) ));
$sth->bind_param(1, $user_supplied_value, { TYPE => SQL_INTEGER });
$sth->execute() or print $sth->errstr, "<br>\n";
Note that "TYPE => SQL_INTEGER" instead of "TYPE => 'SQL_INTEGER'".
It seems to be working now. <sigh>
I hope this helps someone.
Greg M.
Subject
Written By
Posted
Re: Trouble with parameters and IN query
October 29, 2007 11:09PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.