If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Running a program within a transaction

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-07, 08:29
iskander iskander is offline
Registered User
 
Join Date: Sep 2007
Posts: 50
Question Running a program within a transaction

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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On