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 SP/UDF from Trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-22-05, 10:03
jsp2999 jsp2999 is offline
Registered User
 
Join Date: Jul 2004
Posts: 76
Calling SP/UDF from Trigger

Hi All,

Is it possible to call storedprocedure/UDF from trigger?

My DB2 UDB version is 8.1.5.

Thanks in Advance,
Jai
Reply With Quote
  #2 (permalink)  
Old 11-22-05, 11:29
wangzhonnew wangzhonnew is offline
Registered User
 
Join Date: Nov 2005
Location: Toronto
Posts: 65
http://www-128.ibm.com/developerwork...ein/index.html

http://publib.boulder.ibm.com/infoce...d/t0011377.htm

CREATE TABLE t1 ( col1 INTEGER )@
DB20000I The SQL command completed successfully.

CREATE TABLE t2 ( col1 INTEGER )@
DB20000I The SQL command completed successfully.

CREATE PROCEDURE abc(IN p INTEGER) BEGIN INSERT INTO t1 VALUES(p); END@
DB20000I The SQL command completed successfully.

CREATE TRIGGER ins AFTER INSERT ON t2
REFERENCING NEW AS n
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
VALUES ( call_procedure('DB2INST1.ABC', char(new.col1 * 2),
'SAMPLE', 'DB2INST1', 'db2inst1') );
END@
DB20000I The SQL command completed successfully.

INSERT INTO t2 VALUES ( 20 )@
DB20000I The SQL command completed successfully.

-- validate that the trigger has fired - it should update t1
SELECT * FROM t1@

COL1
-----------
40

1 record(s) selected.
__________________
IBM Certified DBA for DB2 UDB
IBM Certified Database Developer for DB2 UDB
DB2 Tech Support, IBM Toronto Software Lab
Reply With Quote
  #3 (permalink)  
Old 11-22-05, 11:57
jsp2999 jsp2999 is offline
Registered User
 
Join Date: Jul 2004
Posts: 76
Is below mentioned link is for 8.1.5 or 8.2?

http://publib.boulder.ibm.com/infoce...d/t0011377.htm
Reply With Quote
  #4 (permalink)  
Old 11-22-05, 12:03
wangzhonnew wangzhonnew is offline
Registered User
 
Join Date: Nov 2005
Location: Toronto
Posts: 65
it's for DB2 V8
__________________
IBM Certified DBA for DB2 UDB
IBM Certified Database Developer for DB2 UDB
DB2 Tech Support, IBM Toronto Software Lab
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