Thread

Posted on Mon Apr 11 17:03:09 2005 by zby
SQL functions in WHERE clause
I need to use a SQL function in the WHERE clause like:
SELECT * FROM link WHERE cachevect @@ tsquery('?')
I cannot find any way to do it with the placeholder - the only solution I found is to use the scalar reference like:
my $where = q{@@ tsquery('} . quote($val) . q{')}; { cachevect => \$where }
but then I loose all the convenience of using binded parameters. Are there any plans to solve that?
Direct Responses: 346 | Write a response
Posted on Fri Apr 15 12:25:10 2005 by zby in response to 321
Re: SQL functions in WHERE clause
Here is a patch against the version:
$Id: Abstract.pm,v 1.17 2004/08/25 20:11:27 nwiger Exp $
diff Abstract.pm Abstract.pm.orig 577,582c577 < if ($k eq 'clause'){ < use Data::Dumper; < print Dumper($v); < push @sqlf, $v->{clause}; < push @sqlv, @{$v->{binds}}; < }elsif (! defined($v)) { --- > if (! defined($v)) {
It allowes to do
my $sqlparams; $sqlparams->{clause} = { clause => 'name @@ ?', binds => [1]}; my($where, @bind) = $sql->where($sqlparams, ['name'], 10, 10);
But it takes the 'clause' key as special.
Write a response