On Thu, 21 Nov 2002, Adam Witney wrote:
> One thing you may want to keep in mind is the situation concerning array
> slices
>
> If you send a statement like this
>
> my $sth = $dbh->prepare("select cube[1:2][1][1] from test4");
>
> Then the :2 gets treated as a placeholder and gets substituted. From the
> trace
Ugg.
Maybe as a possible idea, what do you think?
--- dbdimp.orig Thu Nov 21 15:51:06 2002
+++ dbdimp.c Thu Nov 21 15:56:24 2002
@@ -692,6 +692,8 @@ if (*src != ':' && *src != '?') { if (*src == '\'' || *src == '"') {
in_literal = *src;
+ } else if ('[' == *src) {
+ in_literal = ']'; } *dest++ = *src++; continue;
@@ -1139,6 +1141,8 @@ if (*src != ':' && *src != '?') { if (*src == '\'' || *src == '"') {
in_literal = *src;
+ } else if ('[' == *src) {
+ in_literal = ']'; } *dest++ = *src++; continue;
Untested, but compiles. :) (well I did do a quick test on your above stmt
and it works for that one, but may break other things. YMMV)
>
> dbd_st_execute: statement = >select cube[1NULL][1][1] from test4<
> ERROR: parser: parse error at or near "NULL" at character 14 error 7
> recorded: ERROR: parser: parse error at or near "
> NULL" at character 14
>
> As no parameters have been bound to the placeholder then a NULL is
> substituted and so it fails.
>
> Or maybe I was doing it wrong and there is a way to get around this already?
>
As a quick workaround $dbh->prepare("cube[1:?][1][1]"); make '2' your
first param to execute()
-r