473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to do a commit after each insert inside an SPL ?

Hi,
I had posted one topic earlier, but somehow the link
has been broken and I cannot see the topic. So sorry if
this is a duplicate topic for some. Here is the issue
that I'm running into.
Basically, I have this SPL that does a lot of insert
and update on many different tables. And I also have one
error table that would trap all the information like
SQLCODE, table name, column name, etc.. when an exception
arises. Everything runs fine when there are no exceptions.
But from time to time, when there are rows that cannot be
update/insert into a table, this error table would be
populated with many rows (sometimes over 20,000 rows).
And when this error table is being inserted, the table is
locked. And we get deadlock error when a SQL statement
is issued against the error table.
Is there a way to write a COMMIT statement so that
each time it inserts into the error table, it commits.
I tried adding a commit right after the insert statement,
but I was getting an error saying that there are no
open cursors. Is there a workaround this ?

Here is an example :

------------

CREATE PROCEDURE db2.test ...

BEGIN
DECLARE..
DECLARE..
DECLARE..

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
INSERT INTO db2.ERROR (..)
VALUES (..);
--COMMITS; --want to do a commit here
END;

SET ..
Nov 12 '05 #1
2 2660
Now that makes sense.
It's not your COMMIT that's failing.
The COMMIT closes the cursor.
DECLARE the cursor WITH HOLD and you'll be in business.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:3a*************@individual.net...
Now that makes sense.
It's not your COMMIT that's failing.
The COMMIT closes the cursor.
DECLARE the cursor WITH HOLD and you'll be in business.

Cheers
Serge


Make sure you explicitly close the cursor if you use the WITH HOLD option
when you are finished using the cursor.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: anders_tung | last post by:
Hi, I have a procedure which will call 3 functions. First function will update a record. Second function will delete a record. Third function will insert a record. Each function will return...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
0
by: Fan Ruo Xin | last post by:
Nothing got wrong with DB2 COMMIT, db2 cfg, ... Even you did an "insert some_id+1 ..." immediately after you did "select max(some_id) from .... " in session1. This will not block the operations...
3
by: Mark | last post by:
If a java applicaiton using the type 4 driver calls a DB2 stored procedure, does the stored procedure need to do its own commit when updates are completed? If the stored procedure does a commit or...
7
by: Ugrasena via DBMonster.com | last post by:
Hi team i am using DB2 7.2 on Windows2000. We have lot many SQL Procedure Calls, is there any way i can Turn off the Auto Commit on that Database, the Problem i have is many of our Application...
4
by: MelApiso | last post by:
Hi, I have two databases in the same instance, sourcedb and targetdb. In sourcedb I created one table (t1). In targetdb I created another table (t2). In sourcedb I created one nickname (N2) for...
7
by: annecarterfredi | last post by:
I need to increase the length of CD column from char(5) to char(7) in DB2 V8.2. I am doing it this way: 1. create new_table with CD char(7) 2. do 'insert into new_table select * from...
5
by: Roger | last post by:
backup log testdb with truncate_only DBCC SHRINKFILE (testdb_log, 100) WITH NO_INFOMSGS backup database testdb to disk = '\\DC01\Backups\DB01\testdb.bak' with init and does the shrinkfile...
9
by: eeriehunk | last post by:
Hi All, The important thing about triggers is that, you can't call Transaction Control Statements(commit/rollback) inside a trigger. But what if a trigger is fired and then it makes an entry into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.