If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Out Parameter in Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-11, 07:51
ajh ajh is offline
Registered User
 
Join Date: Apr 2011
Posts: 31
Red face Out Parameter in Procedure

I am on iseries for DB2 5.4

I have an out parameter in a Stored Procedure.

The out parameter contains the following Statement :

CREATE TRIGGER TEST AFTER INSERT ON DEPT REFERENCING NEW AS NEWTFOR EACH ROW MODE DB2SQL BEGIN
DECLARE HSQLCODE INTEGER DEFAULT 0 ;
DECLARE HSQLSTATE CHAR ( 5 ) DEFAULT '00000' ;
DECLARE SQLCODE INTEGER ;
DECLARE SQLSTATE CHAR ( 5 ) ;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION , SQLWARNING , NOT FOUND
VALUES ( SQLCODE , SQLSTATE ) INTO HSQLCODE , HSQLSTATE ;
INSERT INTO DEPTAUDIT(DNO, DNAME, LOC)
VALUES ( NEW.DNO, NEW.DNAME, NEW.LOC)
insert into log values(HSQLCODE , HSQLSTATE);
END;

When I call the procedure CALL TESTPROC(trigname,?) I expect my program to create the TEST trigger and if any error occurs then put the sqlcode and sqlstate in a log table.

How can we execute the statement of the out parameter. Do i have to write another procedure to do this ? Write an SQL to call use the outparameter to create the trigger ? Please help .

When I call the procedure CALL TESTPROC(trigname,?) the procedure runs fine but the trigger does not create nor gives an sqlcode or sqlstate. I checked out and found that the DEPTAUDIT table was not existing. So i created it . even then the trigger is not created.

So i figure out the the CREATE TRIGGER statement is in the out parameter but is not executing . How to execute this CREATE TRIGGER Statement ?




Can we
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On