|
I found this error in my script. I think it is caused by the DBD::PgPP's method execute.
It replaces the ? with the real parameters by using s/\?/xxx/e
So when your leading parameter has ? in their value, the following value will be placed with that parameter. it caused syntax error easily.
i make a patch to PgPP.pm :
===============================================
@@ -355,11 +355,34 @@
if (@$params != $num_param) {
# ...
}
- my $statement = $sth->{Statement};
+# this code will replace the following parameters in the leading parameters' "?"
+# my $statement = $sth->{Statement};
+# for (my $i = 0; $i < $num_param; $i++) {
+# my $dbh = $sth->{Database};
+# my $quoted_param = $dbh->quote($params->[$i]);
+# $statement =~ s/\?/$quoted_param/e;
+# }
+# this code will replace the proper parameters.
+ my $pos = 0;
+ my $leftStatement = $sth->{Statement};
+ my $statement = "";
for (my $i = 0; $i < $num_param; $i++) {
my $dbh = $sth->{Database};
my $quoted_param = $dbh->quote($params->[$i]);
- $statement =~ s/\?/$quoted_param/e;
+ $pos = index ($leftStatement, "?", 0);
+ if ($pos < 0) {
+ last;
+ }
+ if ($pos == 0) {
+ $statement .= $quoted_param;
+ } else {
+ $statement .= substr($leftStatement, 0, $pos) . $quoted_param;
+ }
+ if ($pos + 1 == length($leftStatement)) {
+ last;
+ } else {
+ $leftStatement = substr($leftStatement, $pos + 1);
+ }
}
my $pgsql = $sth->FETCH('pgpp_handle');
my $result;
===============================================
i tested in my script. it is ok.
hope it's helpful to you. |