Un exemple en VB si cela peut vous aider. La procédure stockée accepte 1 parametre en entrée et 2 en sortie
intégrer systeme.data et ibm.idb2.... dans le projet
// Create and open a connection to the iSeries. iDB2Connection cn = new iDB2Connection("DataSource=myiSeries;")
cn.Open() //
// Setup the command to call the stored procedure EMPINFO. iDB2Command cmd = new iDB2Command("sampledb.empinfo", cn)
cmd.CommandType = System.Data.CommandType.StoredProcedure
// Create the parameter definitions.
cmd.Parameters.Add("@employeeId", iDB2DbType.iDB2Char, 6); cmd.Parameters["@employeeId"].Direction = System.Data.ParameterDirection.Input; cmd.Parameters.Add("@firstname", iDB2DbType.iDB2VarChar, 12)
cmd.Parameters["@firstname"].Direction = System.Data.ParameterDirection.Output; cmd.Parameters.Add("@lastname", iDB2DbType.iDB2VarChar, 15); cmd.Parameters["@lastname"].Direction = System.Data.ParameterDirection.Output
cmd.Parameters.Add("@current_salary", iDB2DbType.iDB2Decimal); cmd.Parameters["@current_salary"].Precision = 9; cmd.Parameters["@current_salary"].Scale = 2; cmd.Parameters["@current_salary"].Direction = System.Data.ParameterDirection.Output; // Set the input parameter to one of the employees in the // SAMPLEDB.EMPLOYEE table. For this example, we hard-code // the employee id. cmd.Parameters["@employeeId"].Value = "000180"; // Execute the command. Because the command does not return // a result set, we use ExecuteNonQuery. cmd.ExecuteNonQuery(); // Now, print out the employee first name, last name, // and current salary. Console.WriteLine("{0} {1}'s current salary: {2}", cmd.Parameters["@firstname"].Value, cmd.Parameters["@lastname"].Value, cmd.Parameters["@current_salary"].Value.ToString()); // The return value from our sample stored procedure is the // recommended salary increase. Display that now. Console.WriteLine("Recommended salary increase: " + cmd.Parameters["@rc"].Value.ToString()); // Dispose the command since we no longer need it. cmd.Dispose(); // Close the connection. cn.Close(); |