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 > Calling SQL PL from Trigger with table transition variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-28-04, 11:05
Santosh Kumar Santosh Kumar is offline
Registered User
 
Join Date: Sep 2004
Posts: 6
Calling SQL PL from Trigger with table transition variable

To pass table transition variables from a trigger body to SQL procedure, I'm trying to use table locator as follows --

-- CREATE SQL PROCEDURE --

CREATE PROCEDURE SQLPROC1 (IN TRIG_TBL_ID TABLE LIKE EMPLOYEE AS LOCATOR)
MODIFIES SQL DATA
LANGUAGE SQL
BEGIN
DELETE FROM DEPT WHERE 1=2;
END
@

-- CREATE TRIGGER --

CREATE TRIGGER SQLTR001
AFTER INSERT ON EMPLOYEE
REFERENCING NEW_TABLE AS NEWTAB
FOR EACH STATEMENT MODE DB2SQL
BEGIN ATOMIC
CALL SQLPROC1 (TABLE EMPLOYEE);
END
@

Can anyone confirm whether or not the table locator is supported in SQL Procedure in DB2 V8.1 on UNIX-AIX? And if yes, why the above script is not working? If no, is there any workaround to pass table transition variables from Trigger to SQL PL.

I have confirmed that an SQL Procedure can be CALLed from a trigger body.

any help would be appreciated.

Additional Info:

(1) I do NOT have any problem with compilation or execution of a SQL PL (with no transitive variables) from CLP.

(2) The command used to execute above script is --
db2 -td@ -vf TEMP.sql

(3) Error returned for above queries is --

--FOR SQL PROCEDURE
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "LIKE EMPLOYEE AS LOCATOR" was found following
"IN TRIG_TBL_ID TABLE". Expected tokens may include: "<space>". LINE
NUMBER=1. SQLSTATE=42601

--FOR TRIGGER
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "TABLE" was found following "CALL SQLPROC1 (".
Expected tokens may include: "JOIN <joined_table>". LINE NUMBER=6.
SQLSTATE=42601


Thanks!
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