ISeries Stored Procedure Invoking an RPG Program Does Not Return Value to a Program

I have a stored procedure that calls the SQLRPGLE program. The program works fine, as I checked in the debugger and sent the return value as expected. Instead, returns, looking at cmd.Parameters["@ISMATCH"].Value = {}. I guess I'm doing something wrong. What could it be?

Stored procedure:

CREATE PROCEDURE "MPRLIB"."CHECKHOURS" (EMPLOYEEID DECIMAL(10 , 0), 
    INOUT ISMATCH CHAR(1))
LANGUAGE RPGLE
PARAMETER STYLE SQL
NOT DETERMINISTIC
MODIFIES SQL DATA 
SPECIFIC CHECKHOURS 
NEW SAVEPOINT LEVEL
EXTERNAL NAME 'MPRLIB/MPRLRCHK';

My method:

    public bool IsValidTimesheet(int id)
    {
        bool isValid = false;

        // Get the data from the iSeries
        using (iDB2Connection conn = new iDB2Connection(ConfigurationManager.ConnectionStrings["IbmIConnectionString"].ConnectionString))
        {
            using (iDB2Command cmd = conn.CreateCommand())
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "LIB.CHECKHOURS";

                cmd.Parameters.Add("@EMPLOYEEID", iDB2DbType.iDB2Decimal).Value = id;
                cmd.Parameters.Add("@ISMATCH", iDB2DbType.iDB2Char).Direction = ParameterDirection.Output;
                conn.Open();
                cmd.ExecuteNonQuery();
                isValid = (cmd.Parameters["@ISMATCH"].Value.ToString() == "1") ? true : false;
                conn.Close();
            }
        }

        return isValid;
    }

My RPG program parameters:

 D CHECKHOURS      PR                  extpgm('CHECKHOURS')
 D  id                           10P 0
 D  isMatch                       1A
+3
source share
3 answers

Solution should be

CREATE PROCEDURE "MPRLIB"."CHECKHOURS" (EMPLOYEEID DECIMAL(10 , 0), 
    INOUT ISMATCH CHAR(1))
    LANGUAGE RPGLE
    PARAMETER STYLE GENERAL
    NOT DETERMINISTIC
    MODIFIES SQL DATA 
    SPECIFIC CHECKHOURS 
    NEW SAVEPOINT LEVEL
    EXTERNAL NAME 'MPRLIB/MPRLRCHK';

Thanks to Schadd on MIDRANGE-L .

+1
source

, , , OUT, INOUT - , RPG . , proc INOUT #?

+1

And what if you change the out parameter to nvarchar (1) and change the sproc. Does type N match type iDB2Char?

0
source

All Articles