dbTalk Databases Forums  

Re: [Info-Ingres] DEP, For loop and commit

comp.databases.ingres comp.databases.ingres


Discuss Re: [Info-Ingres] DEP, For loop and commit in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karl Schendel
 
Posts: n/a

Default Re: [Info-Ingres] DEP, For loop and commit - 11-02-2011 , 05:59 AM






On Nov 2, 2011, at 7:48 AM, Martin Bowes wrote:

Quote:
Hi All,

I have a database procedure which uses a for loop to control a large amount of processing. The body of the for loop has places where status messages are inserted in a table, plus many places where a database error could occur on other tasks.

The trouble is that if an error occurs then it causes a rollback in the directly exected procedure. This then erases all my status messages from the table.
Oops. I guess this is one situation where some sort of multiple or nested transaction
might help.

Quote:
So it occurred why not commit each status message insert….

But the for loop terminated on the first commit! Is it meant to do that? I didn't expect that, but reading between thelines on the commit documentation I suppose I'm not too surprised.
Thinking about the implementation, I'm not too surprised either. The FOR loop is the closest
thing in DB procedure-land to a cursor. The commit would close and reopen the loop table
but it would lose the current position. I guess that somehow tells the FOR loop control to
stop looping.

Quote:
I'm thinking of attempting to rewrite the procedure to use a while loop, but I suspect the commit will have the same effect.
WHILE loops have no direct tie to a driving table, so that might actually work.

Karl

Reply With Quote
  #2  
Old   
Martin Crouch
 
Posts: n/a

Default Re: [Info-Ingres] DEP, For loop and commit - 11-02-2011 , 06:17 AM






Try this for debug logging in a DB procedure:

message 'proc5 entered' with destination = (error_log);


It writes the message to your $II_SYSTEM/files/errlog.log and is very
useful for debugging rules+procedures.

Reply With Quote
  #3  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] DEP, For loop and commit - 11-02-2011 , 06:39 AM



Hi Karl,

Yes I just wrote a quicky test and the while loop will get around the problem.

Sweet!

Marty

-----Original Message-----
From: Karl Schendel [mailto:schendel (AT) kbcomputer (DOT) com]
Sent: 02 November 2011 12:00
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] DEP, For loop and commit


On Nov 2, 2011, at 7:48 AM, Martin Bowes wrote:

Quote:
Hi All,

I have a database procedure which uses a for loop to control a large amount of processing. The body of the for loop has places where status messages are inserted in a table, plus many places where a database error could occur on other tasks.

The trouble is that if an error occurs then it causes a rollback in the directly exected procedure. This then erases all my status messages from the table.
Oops. I guess this is one situation where some sort of multiple or nested transaction
might help.

Quote:
So it occurred why not commit each status message insert....

But the for loop terminated on the first commit! Is it meant to do that? I didn't expect that, but reading between thelines on the commit documentation I suppose I'm not too surprised.
Thinking about the implementation, I'm not too surprised either. The FOR loop is the closest
thing in DB procedure-land to a cursor. The commit would close and reopen the loop table
but it would lose the current position. I guess that somehow tells the FOR loop control to
stop looping.

Quote:
I'm thinking of attempting to rewrite the procedure to use a while loop, but I suspect the commit will have the same effect.
WHILE loops have no direct tie to a driving table, so that might actually work.

Karl



_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.