Let me begin by apologizing for any stupid question I might ask as I am profane in regards to DB2 and AS400.
I am using the iSeries .net managed provider to call programs on AS400 and the purpose is to call several programs on the same transaction. If I try to call the program as a stored procedure such as:
iDB2Command cmd = new iDB2Command("ALBFXFK", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Transaction = transaction;
cmd.DeriveParameters();
cmd.Parameters[0].Value = "";
…
…
…
int i = cmd.ExecuteNonQuery();
transaction.Rollback();
cn.Close();
it doesn’t like it and it throws an exception on the DeriveParameters call:
The stored procedure cannot be found in SYSPROCS, or the procedure name is ambiguous.
I don’t fully understand how AS400 works but I am sure the proc is registered and I even found this stored procedure in the sysprocs file:
select * from qsys2.sysprocs where specific_name = 'ALCBXFK';
Then I’ve been doing some reading and I found that in every code sample on the IBM website, no matter of the language or provider being used the code always uses a commandtext to call the programs instead of stored procedure. If I use this code:
iDB2Command cmd = new iDB2Command(@"{CALL ACSLPGM.ALBFXFK (?,?,?,?,?,?,?,?,?,?)}", cn);
cmd.CommandType = CommandType.Text;
cmd.Transaction = transaction;
cmd.DeriveParameters();
cmd.Parameters[0].Value = "";
…
…
…
int i = cmd.ExecuteNonQuery();
transaction.Rollback();
cn.Close();
then it does run the program, and the program does its inserts but the transaction does not rollback.
What am I doing wrong and how can I achieve the transactional behaviour on the program calls?
Cheers,
Dani