Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / March 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
harborboy76@yahoo.com - 22 Mar 2005 18:34 GMT
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 ..
.
.
.
INSERT..
.
.
UPDATE..
.
.

END

-----------
Serge Rielau - 22 Mar 2005 18:44 GMT
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

Signature

Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

Mark A - 22 Mar 2005 19:19 GMT
> Now that makes sense.
> It's not your COMMIT that's failing.
[quoted text clipped - 3 lines]
> Cheers
> Serge

Make sure you explicitly close the cursor if you use the WITH HOLD option
when you are finished using the cursor.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.