Re: Problem calling External Procedure with REFCURSOR
- From: mchase@xxxxxxxxxxxxx (Michael A Chase)
- Date: Wed, 04 May 2005 18:43:05 -0700
On 05/04/2005 02:40 PM, Denesa K Shaw said:
Any Ideas on why I'm getting this error? It appears not to like my date that I'm passing to it. I printed the date to a log and it looks ok, any ideas?
Error:
DBI::st=HASH(0x20391b00)->bind_param(...): attribute parameter
'TO_DATE('01/02/200','mm/dd/yyyy hh24:mi:ss')'
> is not a hash ref at CallTest_firstsp.pl line 90.
The error is exactly what it says it is. You put a string in a subroutine parameter where a hash refrence is expected.
.. . .My Code: #!/usr/bin/perl -w
use lib "/usr/xxx/xxx/xxx/scripts"; use TMH; use DBD::Oracle qw(:ora_types);
################################################################################## # Declarations Needed for Scripts ##################################################################################
use constant SCRIPT_ERROR => "RELOAD_HISTORICAL_DATA"; $RELOAD_FILE_NM = ""; $LAST_ATTEMPT_TS = ""; $RELOAD_FILE_TS = ""; $INB_OUTB_IN = ""; $LOGICAL_NM = ""; $starttimeStamp= "'01/01/2005 08:49:00'"; $endtimeStamp= "'01/02/2005 08:49:00'"; $In_Start_File_Ts = "TO_DATE(" . $starttimeStamp . ", 'mm/dd/yyyy hh24:mi:ss')"; $In_End_File_Ts = "TO_DATE(" . $endtimeStamp . ",'mm/dd/yyyy hh24:mi:ss')";
$sql = qq( BEGIN PACKAGE.PROCEDURE(:p1,:cursor_name); END; );
my $func = $dbh->prepare($sql); $func->bind_param(":p1",$In_Start_File_Ts,$In_End_File_Ts); $func->bind_param_inout(":cursor_name", \$cursor_name, 0,{ ora_type=>ORA_RSET } ); $func->execute;
Placeholders (AKA bind variables) take __VALUES__, not substitution strings. Also you can only provide one value for each placeholder. If the procedure you are calling takes a start datetime and an end datetime, it needs two parameters for that.
Try this (requires a procedure that takes 2 date arguments and returns one cursor):
my $sql = qq(
BEGIN
PACKAGE.PROCEDURE( TO_DATE( :start, :fmt ), TO_DATE( :end, :fmt ),
:cursor );
END;
); my $func = $dbh -> prepare( $sql );
$func -> bind_param( ":start", $In_Start_File_Ts );
$func -> bind_param( ":end", $In_End_File_Ts );
$func -> bind_param( ":fmt", "mm/dd/yyyy hh24:mi:ss" );
$func -> bind_param_inout( ":cursor", \$cursor, 0,
{ ora_type=>ORA_RSET } );-- Mac :}) ** I usually forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age. .
- References:
- Problem calling External Procedure with REFCURSOR
- From: Denesa K Shaw
- Problem calling External Procedure with REFCURSOR
- Prev by Date: Re: DBI, Postgresql, and the SQL_DATE type
- Next by Date: Re: DBD::Oracle implementation
- Previous by thread: Problem calling External Procedure with REFCURSOR
- Index(es):
Relevant Pages
|
|