I've been trying trying to use an action stored proc with some difficulty. The stored proc in the db looks like this:
CREATE OR REPLACE PROCEDURE "CAP13TEST"."GET_LTLKEY_NUMBER" (
what_counter IN VARCHAR2, next_number OUT NUMBER) AS
temp_number NUMBER;
BEGIN
SELECT SYSCOUNT_VAL
INTO temp_number
FROM SYSCOUNTER
WHERE SYSCOUNT_TAB = what_counter
FOR UPDATE NOWAIT;
temp_number := temp_number + 1;
UPDATE SYSCOUNTER
SET SYSCOUNT_VAL = temp_number
WHERE SYSCOUNT_TAB = what_counter;
next_number := temp_number;
COMMIT;
END;
Nothing much to it... but it results in an action proc which looks like this:
public static int GET_LTLKEY_NUMBER(System.String wHAT_COUNTER, ref System.Int16 nEXT_NUMBER, DataAccessAdapter adapter)
{
// create parameters
OracleParameter[] parameters = new OracleParameter[2];
parameters[0] = new OracleParameter("WHAT_COUNTER", OracleDbType.Varchar2, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current, wHAT_COUNTER);
parameters[1] = new OracleParameter("NEXT_NUMBER", OracleDbType.Decimal, 0, ParameterDirection.Output, true, 0, 0, "", DataRowVersion.Current, nEXT_NUMBER);
// Call the stored proc.
int toReturn = adapter.CallActionStoredProcedure("GET_LTLKEY_NUMBER", parameters);
if(parameters[1].Value!=System.DBNull.Value)
{
nEXT_NUMBER = (System.Int16)parameters[1].Value;
}
return toReturn;
}
the initial error message i got told me that the precision value for the NEXT_NUMBER param was out of range, that it had to be between 1 and 38. So i changed that to 38 but then i started getting invalid cast errors. Anyway, to cut a long story short (ish) i had to change the NEXT_NUMBER params to Int32, e.g.
public static int GET_LTLKEY_NUMBER(System.String wHAT_COUNTER, ref System.Int32 nEXT_NUMBER, DataAccessAdapter adapter)
{
// create parameters
OracleParameter[] parameters = new OracleParameter[2];
parameters[0] = new OracleParameter("WHAT_COUNTER", OracleDbType.Varchar2, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current, wHAT_COUNTER);
parameters[1] = new OracleParameter("NEXT_NUMBER", OracleDbType.Int32, 0, ParameterDirection.Output, true, 38, 0, "", DataRowVersion.Current, nEXT_NUMBER);
// Call the stored proc.
int toReturn = adapter.CallActionStoredProcedure("GET_LTLKEY_NUMBER", parameters);
if(parameters[1].Value!=System.DBNull.Value)
{
nEXT_NUMBER = (System.Int32)parameters[1].Value;
}
return toReturn;
}
and now all seems well