Consultor Eletrônico



Kbase P92143: How to add debugging output to a SQL-92 stored procedure or trigger
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/15/2009
Status: Verified

GOAL:

How to add debugging output to a SQL-92 stored procedure or trigger

GOAL:

How to debug Java stored procedures and triggers for SQL-92

GOAL:

Sample of a Java trigger with debug traces

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

To add output to SQL-92 stored procedures and triggers for debugging purposes, write the desired information to a text file using Java code. The following sample uses the FileWriter class from the java.io package.
CREATE TRIGGER PUB.sampleTrigger
AFTER INSERT
ON PUB.MYTABLE1
REFERENCING NEWROW
FOR EACH ROW
IMPORT
import java.io.*;
BEGIN
int myvar = 7;

int mynum = ((Integer)NEWROW.getValue(1,myvar)).intValue();
try {
FileWriter mystream= new FileWriter("trigger.log",true);
mystream.write("\nAfter NEWROW.getValue");
mystream.write("\nGot value: " + mynum);
mystream.close();
} catch (Exception e) {;}
myvar = myvar + mynum;
SQLIStatement insert_to_myTable2 = new SQLIStatement ("INSERT INTO myTable2 values (" + myvar +")");
insert_to_myTable2.execute();
END