This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2 Replies Last post: Feb 8, 2010 12:30 PM by Shawn Fox  
Parag   9 posts since
Oct 15, 2009
Currently Being Moderated

Feb 8, 2010 4:37 AM

Autonomous Transactions for error logging

Hello,

 

we are having a requirement for logging the steps in stored procedure.

 

However, the problem is that if any step errors out, the entire procedure, including the logging (done by calling logging procedures in main procedure) gets rolled back. Hence neither can we see the changes done by the successful steps above the error step nor is any sort of logging recorded (for earlier successful steps and the errored step).

 

Is ther a way to resolve this.

Can Autonomous transaction be used in Netezza?

 

Thanks,

Parag

David Birmingham   153 posts since
Sep 24, 2007
Currently Being Moderated
1. Feb 8, 2010 9:09 AM in response to: Parag
Re: Autonomous Transactions for error logging

For the maximum visibility for operators, troubleshooters etc, logging should be the domain of flat log files. It is the only way to preserve the chain of events with complete context.

 

Also avoid having too many disparate or unrelated SQL operations in the same proc. A proc's reason for existence is to solve a difficult feature issue, not be the "place where all ELT runs". That's why it's a procedure, rather than a program.

Shawn Fox   388 posts since
Aug 15, 2006
Currently Being Moderated
2. Feb 8, 2010 12:30 PM in response to: Parag
Re: Autonomous Transactions for error logging

The simple way is to use RAISE NOTICE to put debug messages into your code.  If that isn't acceptable you could write a UDX which logs information to a file or possibly even invokes nzsql to insert a record into a table (very inefficient).  See the section "Using UDXs with Stored Procedures" in the onstream dev guide for basic information as to how this can be done.

More Like This

  • Retrieving data ...