It's hard to say, without knowing what your procs are doing. You're basically doing some crude polymorphism here (kinda, sorta). Quite possibly this will all be easier to handle directly in PL/SQL with an overriden "wrapper" proc.
But if you must use a Perl wrapper, you need to keep in mind that you can't "re-prepare" a statement, which is what looks like you're trying to do. That is, if you're going to run just one proc, you should prepare and execute just once. For example, the second part of this:
isn't re-using the statement handle you prepared immediately before, it's clobbering it. For each call that you want to execute, you need to prepare it and bind its parameters separately.if($procName ne ''){ # This is the default call to stored proc. $procedure = "BEGIN "."$procName"."(?, ?); "."END;"; print $procedure, "\n"; print "After Connection\n"; $function = $dbh->prepare($procedure); # # ... <snip> # if($procName eq "PAR_REPORTS_POS.SUN_PRC_AT_I_POSM1W001"){ $procedure = "BEGIN "."$procName"."(?, ?, ?, ?); "."END;"; $function = $dbh->prepare($procedure); $function->bind_param_inout(3,$finRepId,SQL_VARCHAR);
Basically, you need to arrange your code to dispatch to a single prepare and execute based on the name it's passed. You can either do this with a hash or a dispatch structure, like one of the ones in perlsyn, the section labelled "Basic BLOCKs and switch statements".
Again, as I mentioned, the best may be to do all in PL/SQL, but it's hard to say without seeing the procs.
In reply to Re: DBI Execute problem
by VSarkiss
in thread DBI Execute problem
by Nesh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |