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 > How to Create an after insert trigger with a call statement in DB2 UDB V8.1 FixPack 7

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-06, 03:03
maheshbs maheshbs is offline
Registered User
 
Join Date: Mar 2006
Posts: 12
How to Create an after insert trigger with a call statement in DB2 UDB V8.1 FixPack 7

Hi,

Can any body provide some assistance on creating an after trigger in DB2 UDB V8.1 with a call to a Stored Procedure.
The Stored Procedure modifies SQL data and also the transition variable "NEW" is to be updated in the trigger.

The trigger code is givenj below:-

CREATE TRIGGER trgLocChngTranSrl1 AFTER INSERT ON TABMPLOCATIONCHANGE
REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL

BEGIN ATOMIC

DECLARE vcNewRowId VARCHAR(40);



DECLARE nCount FLOAT;



CALL PRCRECORDIDGENERATION('-1','MN','LocationChange',CAST (NULL AS VARCHAR(1)),
CAST (NULL AS VARCHAR(1)),CAST (NULL AS VARCHAR(1)),CAST (NULL AS VARCHAR(1)),CAST (NULL AS VARCHAR(1)),vcNewRowId);



SET NEW.INTTRANSACTIONSERIALNUMBER = ORA.ROUND(ORA.TO_NUMBER(vcNewRowId));

END!

The error message is:-

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0797N The trigger "DB2ADMIN.TRGLOCCHNGTRANSRL1" is defined with an
unsupported triggered SQL statement. LINE NUMBER=21. SQLSTATE=42987

Kindly provide the necessary alternatives to create this type of a trigger

Regards,
Mahesh.B.S
__________________
Mahy
Reply With Quote
  #2 (permalink)  
Old 06-23-06, 04:24
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
You cannot use the SET - command in an AFTER trigger as the insert is already done

you must use the UPDATE table statement if you need to change the values just inserted.
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