Perl DBD::Informix and IDS9.40 SPL display labels
Posted in 2003
Topics: Stored Procedures & SPL
Hi,All
I'm using: 9.40.UC1E1 on RedHat 7.3, perl5.8.0, DBD::Informix 2003.04.
SPL function:
create function test1(a integer)
returning integer as test1_res; return 1;
end function
In perl script:
my $sth = $dbh->prepare('EXECUTE FUNCTION test1(1)');
$sth->execute;
statement "$sth->fetchrow_hashref" returns { 'test1_res' => 1 }.
But, if calling via 'EXECUTE FUNCTION test1(?)', and $sth->execute(2);
statement "$sth->fetchrow_hashref" returns { '(expression)' => 1 }.
It's possible to receive labels in 2nd variant? (with placeholders).
--
Best regards,
Sergey
Sergey Leschenko wrote:
> I'm using: 9.40.UC1E1 on RedHat 7.3, perl5.8.0, DBD::Informix 2003.04.
> SPL function:
> create function test1(a integer)
> returning integer as test1_res;> return 1;
> end function
>
> In perl script:
> my $sth = $dbh->prepare('EXECUTE FUNCTION test1(1)');
> $sth->execute;
> statement "$sth->fetchrow_hashref" returns { 'test1_res' => 1 }.
>
> But, if calling via 'EXECUTE FUNCTION test1(?)', and $sth->execute(2);
> statement "$sth->fetchrow_hashref" returns { '(expression)' => 1 }.
>
> It's possible to receive labels in 2nd variant? (with placeholders).
Apparently not. I'm tempted to call it a bug, but it isn't quite that
simple.
First, the problem is generic; it is merely coincidental the
DBD::Informix is showing it to you. DB-Access doesn't count; it
doesn't support placeholders.
If you wrote an ESQL/C application (eg DBD::Informix), then it would
be told by the server about the return types.
So, why isn't it a simple bug? Because of function overloading!
You might also have a function:
CREATE FUNCTION test1(a DATETIME YEAR TO SECOND) RETURNING VARCHAR(30)AS plunket;
RETURN(a + 1 UNITS SECOND);
END FUNCTION;
And now, until the actual parameter is passed from client to server,
the server cannot tell whether the call should be routed to the first
function -- yours -- or the second -- mine.
There's a strong presumption at the time of prepare that actually it
will go to your function (because you hadn't created my function), but
I'm guessing that the indeterminacy is the cause of the trouble.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/