vikas.rana has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everybody !!,
I am trying to call a stored procedure of DB2 from my perl program the signature of the stored procedure is as below:
CREATE PROCEDURE MyProcedure( IN v_M_FILE_ID VARCHAR(20), INOUT v_M_TRL_REC_CNT_VAR_N INT, INOUT v_M_FILE_RUL_01_C VARCHAR(10), INOUT v_M_FILE_RUL_02_C VARCHAR(10), INOUT v_M_FILE_RUL_03_C VARCHAR(10), INOUT v_M_FILE_RUL_04_C VARCHAR(10), INOUT v_M_D_VLID_APPL_NM VARCHAR(20), INOUT v_M_D_VLID_TY_C VARCHAR(10))
I am calling this procedure using the following statements:
my ($M_TRL_REC_CNT_VAR_N, $M_FILE_RULE_01_C, \ $M_FILE_RULE_02_C, $M_FILE_RULE_03_C, \ $M_FILE_RULE_04_C, $M_D_VLID_APPL_NM, \ $M_D_VLID_TY_C); $sql = "CALL MyProcedure(\'$file_id\', $M_TRL_REC_CNT_VAR_N, \'$M_FILE_RULE_01_C\', \'$M_FILE_RULE_01_C\', \'$M_FILE_RULE_01_C\', \'$M_FILE_RULE_01_C\', \'$M_D_VLID_APPL_NM\', \'$M_D_VLID_TY_C\')" ; $sth = $dbh->prepare( $sql_ref ) or die "Can't prepare statement $sql_ref: DBI::errstr"; $rc = $sth->execute or die "Can't execute statement: $DBI::errstr"; if ( $DBI::err ) { die "Can't execute statement: $DBI::errstr" ; }
On executing this piece of code, I am getting error as follows:
DBD::DB2::st execute failed: [IBM][CLI Driver][DB2/SUN] SQL0104N An unexpected token "," was found + following "LE_CTRL('fsaifdvd ',". Expected tokens may include: "<s +pace>". SQLSTATE=42601
If anybody has any idea about how to call stored procedures that have inout and out type of parameters, kindly provide some input !! Thanks in advance. Vicky

Replies are listed 'Best First'.
Re: Calling Stored Procedure using DBI/DBD::DB2 on perl
by castaway (Parson) on Apr 21, 2004 at 11:38 UTC
    Since I don't see "LE_CTRL(" anywhere in your code here, I assume its part of the procedure content?

    The error sounds like the one I got all the time, trying to create an SQL procedure, because I used a ; to end the entire create procedure statement, and also internally in the procedure to end code lines, which doesnt work.

    Can you call the procedure from the db2 command line with parameters, etc? Also, try printing the contents of $sql after you have created it, and make sure it contains what you think.

    C.