Into this example, we execute a stored procedure: CR/CUSTPARAM3.
The CR/CUSTPARAM3 procedure has been created on IBMi by the following way, by using IBM I Access Client Solution:
CREATE PROCEDURE CR.CUSTPARAM3 ( IN name CHAR(4))
LANGUAGE SQL
SPECIFIC CR.CUSTPARAM3
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
SET OPTION ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *CHG ,
DFTRDBCOL = *NONE ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
SRTSEQ = *HEX
P1 : BEGIN ATOMIC
UPDATE EASYCOMXMP.SP_CUST SET LASTNAME=name WHERE FIRSTNAME='Louis' ;
END P1 ;
EacCommand sqlCommand = ConnectionIBM.CreateCommand();
sqlCommand.CommandText = "CR/CUSTPARAM3";
sqlCommand.CommandType = CommandType.StoredProcedure;
///1st method to fill input parameter
EacParameter param1 = sqlCommand.Parameters.Add("name", DbType.String, 4);
param1.Direction = ParameterDirection.Input;
param1.Scale = 0;
param1.Value = "TU";
// 2nd method
string test = "TA";
sqlCommand.Parameters.Add(new EacParameter("name", test));
// 3rd method
sqlCommand.Parameters.Add(new EacParameter("name","TO"));
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();