Hi,
CLI expects that the return value from stored procedure is always bound
with variable of type SQL_C_LONG. The reason being the data type of the
return value from a Stored Procedure is always of type SQL_INTEGER. To
handle this we have fixed the DBD-DB2 driver with the patch below. You
can apply the patch and try making a stored procedure call as mentioned
below to get the output from a stored procedure.
Patch for dbdimp.c
===================
diff dbdimp.c_new dbdimp.c_version1.80
2436,2449d2435
< SQLPOINTER datap;
< switch (ctype) {
< case SQL_C_SHORT:
< case SQL_C_LONG:
< datap = &phs->ivValue;
< break;
< case SQL_C_FLOAT:
< case SQL_C_DOUBLE:
< datap = &phs->dblValue;
< break;
< default:
< datap = phs->buffer;
< break;
< }
2457c2443
< datap,
---
Show quoted text> phs->buffer,
2462,2464d2447
<
< phs->cType = ctype; /*Set the cType of the variable to which
the parameter is bound*/
<
2561,2570c2544,2547
< if( phs->cType ==
SQL_C_LONG || phs->cType == SQL_C_SHORT ) {
<
sv_setiv(phs->sv, phs->ivValue);
< } else if( phs->cType
== SQL_C_DOUBLE || phs->cType == SQL_C_FLOAT ) {
<
sv_setnv(phs->sv, phs->dblValue);
< } else {
< sv_setpvn(
phs->sv, phs->buffer, phs->indp );
< if( phs->indp >
phs->bufferSize )
< warn(
"Output buffer too small, data truncated "
<
"for parameter '%s'", key );
< }
---
Show quoted text> sv_setpvn( phs->sv,
phs->buffer, phs->indp );
Show quoted text> if( phs->indp >
phs->bufferSize )
Show quoted text> warn( "Output
buffer too small, data truncated "
Show quoted text>
"for parameter '%s'", key );
Patch for dbdimp.h
==================
diff dbdimp.h_new dbdimp.h_version1.80
108d107
< SQLSMALLINT cType; /* The parameter cType
*/
115,116d113
< IV ivValue; /*integer variable to hold the
bound output value */
< double dblValue; /*double variable to hold the
bound output value*/
Changes needed in the Perl program
==================================
You will need to specify the db2_c_type in the bind_param_inout call as
below
$sth->bind_param_inout( 1, \$bind_value, 4, {'db2_c_type' => SQL_C_LONG});
Let us know if you need any clarifications or if finding any difficulty
applying the patch.
--
Thanks
Praveen
IBM OpenSource Application Development Team
India Software Labs, Bangalore (India)