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 > Strange procedure requirement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-07, 10:57
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Strange procedure requirement

I have a stored procedure which manipulates data in certain tables (and followed by a commit statement always).

Now my requirement is just to test whether this procedure is running fine so I don't want any data to be manipulated by this stored procedure.

So if I run the procedure as below will it satisfy my requirement ?
db2 +c "call proc_name()"
db2 rollback.

PS: I have around 50 such procedure so I do not want to comment out any existing DML operations within the procedure.
Env : DB2 V8.2 / AIX 5.3
Reply With Quote
  #2 (permalink)  
Old 08-16-07, 11:40
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by db2udbgirl
I have a stored procedure which manipulates data in certain tables (and followed by a commit statement always).

Now my requirement is just to test whether this procedure is running fine so I don't want any data to be manipulated by this stored procedure.

So if I run the procedure as below will it satisfy my requirement ?
db2 +c "call proc_name()"
db2 rollback.

PS: I have around 50 such procedure so I do not want to comment out any existing DML operations within the procedure.
Env : DB2 V8.2 / AIX 5.3
wouldn't it be the following to turn off autocommit?

db2 -c- "call proc_name()"

Anyway you should try it on a test environment first.

Andy
Reply With Quote
  #3 (permalink)  
Old 08-16-07, 12:05
jsharon1248 jsharon1248 is offline
Registered User
 
Join Date: Apr 2007
Location: Chicago
Posts: 57
I'm not understanding where the commit is located. Is it in the stored proc following the DML, or is it in the script that calls the stored proc? If the commit is in the stored proc, you're out of luck. If it's in the script, what you're thinking should work. The default for the 'c' option is autocommit on, so issuing the 'c' option will turn autocommit off.

But like ARWinner said, test it to make sure. If you can't run the same stored procs in a test environment, create new ones for yourself.
Reply With Quote
  #4 (permalink)  
Old 08-16-07, 16:25
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Commit is present within the stored procedure after DML. Thanks for the comment. Let me start my work on test env.
Reply With Quote
  #5 (permalink)  
Old 08-17-07, 04:40
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Using -c- or +c will turn auto-commit off in the CLP. Using just -c will turn it on if it happens to be turned of via the DB2OPTIONS environment variable, for example.

Since you commit inside the SP, then your only chance is to use a test environment. The commit operation inside the SP tells DB2 to make all changes persistent. Once this is done, the subsequent rollback applies to a new transaction that is implicitly started after the preceding commit/rollback.

Unless you really have problems with network latency, I would recommend that you remove the COMMIT operation from the stored procedures. Transactional control should be left to the client application. Who knows in which context those procedures will be called and then interfere with the transactions that the client thinks it controls?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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