Skip Menu |

This queue is for tickets about the DBIx-ProcedureCall CPAN distribution.

Report information
The Basics
Id: 65772
Status: resolved
Priority: 0/
Queue: DBIx-ProcedureCall

People
Owner: thilo [...] cpan.org
Requestors: austria_rules [...] yepmail.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.03



Subject: bug when calling a procedure from within an anonymous sub
Date: Wed, 16 Feb 2011 11:54:42 +0100
To: bug-DBIx-ProcedureCall [...] rt.cpan.org
From: "Ronald of Steiermark" <austria_rules [...] yepmail.net>
Module Version: 0.10 Perl Version: 5.8.8 (ActiveState) Platform: Windows 2000, Oracle Assume that we have a stored procedure (*not* function) PACK.pr_myProc, which I include in my Perl program with use DBIx::ProcedureCall qw(PACK.pr_myProc); When I invoke this procedure, and - the invokation is the last statement in a Perl-block, and - the block is contained in an anonymous Perl subroutine, then Oracle complains PLS-00222: no function with name 'PR_MYPROC' exists in this scope Note that Oracle complains about a missing FUNCTION. Of course pr_myProc is a procedure, and no function of this name exists. It seems that ProcedureCall somehow believes that this procedure needs to be called as a function, and passes this information to Oracle. Example: sub call_it(&) { $_[0]->() } my $dbh=......; # get database handle call_it { PACK_pr_myProc($dbh) } # This causes the error END { PACK_pr_myProc($dbh) } # This too Workaround: Ensure that the call is not the last statement in a block. Example: call_it { PACK_pr_myProc($dbh); undef } # This works END { PACK_pr_myProc($dbh); undef } # This too -- Ronald Fischer <austria_rules@yepmail.net> There are 10 types of people in the world: those who understand binary and those who don't.
Show quoted text
> It seems that > ProcedureCall somehow believes that this procedure needs to be called as > a function, and passes this information to Oracle.
I will dig into this a little deeper tomorrow, but at first glance it seems like this is working according to spec. Please see the "Procedures and Functions" section in the Perldoc: http://search.cpan.org/~thilo/DBIx-ProcedureCall-0.11/ProcedureCall/Oracle.pm "DBIx::ProcedureCall needs to know if you are about to call a function or a procedure (because the SQL is different). You have to make sure you call the wrapper subroutines in the right context (or you can optionally declare the correct type)" If Perl tells the module that it the subroutine is called in non-void context (which is apparently the case in the examples you gave), the the module will look for an Oracle function. Since this mechanism is a bit flaky (as you have found out), the recommended solution is to declare the procedure to be procedure: use DBIx::ProcedureCall qw(PACK.pr_myProc:procedure);
Subject: Re: [rt.cpan.org #65772] bug when calling a procedure from within an anonymous sub
Date: Wed, 16 Feb 2011 15:59:21 +0100
To: "Thilo Planz via RT" <bug-DBIx-ProcedureCall [...] rt.cpan.org>
From: "Ronald of Steiermark" <austria_rules [...] yepmail.net>
On Wed, 16 Feb 2011 08:19 -0500, "Thilo Planz via RT" <bug-DBIx-ProcedureCall@rt.cpan.org> wrote: Show quoted text
> > It seems that > > ProcedureCall somehow believes that this procedure needs to be called as > > a function, and passes this information to Oracle.
> > I will dig into this a little deeper tomorrow, but at first glance it > seems like this is working according to spec. > > Please see the "Procedures and Functions" section in the Perldoc: > http://search.cpan.org/~thilo/DBIx-ProcedureCall-0.11/ProcedureCall/Oracle.pm > "DBIx::ProcedureCall needs to know if you are about to call a function > or a procedure (because the SQL is different). You have to make sure you > call the wrapper subroutines in the right context (or you can optionally > declare the correct type)"
I understand, though this doesn't explain yet why this appears only in anonymous subroutines. Well, maybe I have to investigate here a bit more. Thanks for pointing out these docs. I was not aware that a documentation for DBIx::ProcedureCall::Oracle exists. Show quoted text
> Since this mechanism is a bit flaky (as you have found out), the > recommended solution is to declare the procedure to be procedure: > > > use DBIx::ProcedureCall qw(PACK.pr_myProc:procedure);
Thanks a lot. This is what I will use. Ronald -- Ronald Fischer <austria_rules@yepmail.net> There are 10 types of people in the world: those who understand binary and those who don't.
Show quoted text
> > I will dig into this a little deeper tomorrow
> I understand, though this doesn't explain yet why this appears only in > anonymous subroutines. Well, maybe I have to investigate here a bit > more.
It does seem to work better if ProcedureCall is not involved (with a plain Perl subroutine). Consider the following test case: sub what_do_you_want{ print defined wantarray ? "something\n" : "nothing\n"; } sub call_it(&) { $_[0]->() } my $x = what_do_you_want(); # "something" OK what_do_you_want(); # "nothing" OK call_it { what_do_you_want(); }; # "nothing" OK DBIx fails here END { what_do_you_want() } # "something" NG but unspec'd (*) (*) perldoc -f wantarray: "wantarray()"’s result is unspecified in the top level of a file, in a "BEGIN", "UNITCHECK", "CHECK", "INIT" or "END" block, or in a "DESTROY" method. Show quoted text
> > Thanks for pointing out these docs. I was not aware that a > documentation > for DBIx::ProcedureCall::Oracle exists.
Yeah, that should maybe be clearer, especially since there are a lot of useful Oracle-specific features described in there.