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 > symbol in trigger definition

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-15-10, 14:00
surjyakp surjyakp is offline
Registered User
 
Join Date: Jan 2010
Posts: 26
symbol in trigger definition

Hi,
I found a symbol like '--' in below mentioned trigger

CREATE TRIGGER RQ5.CNTRL_LST_UPDT
AFTER UPDATE OF UPDT_DT ON RQ5.CNTRL_LST_ITM
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW MODE DB2SQL
WHEN (NEW.CNTRL_LST_ID < 1000)
BEGIN ATOMIC
INSERT INTO RQ5.CNTRL_LST_ITM_HIST(CNTRL_LST_ID,ITM_ID,HIST_TM STMP,HIST_REAS_TYP,AGE,DECD,
ENTRED_DT,UPDT_DT,AS_OF_DT,DOB,LST_NM,FRST_NM,CATG _ID,TITL,POSN,PLACE_OF_BTH,EDITOR,SBS_SCOR_VAL)
VALUES(OLD.CNTRL_LST_ID,OLD.ITM_ID,CURRENT TIMESTAMP,'CC',OLD.AGE,OLD.DECD,OLD.ENTRED_DT,
OLD.UPDT_DT,OLD.AS_OF_DT,OLD.DOB,OLD.LST_NM,OLD.FR ST_NM,OLD.CATG_ID,OLD.TITL,OLD.POSN,OLD.PLACE_OF_B TH,
OLD.EDITOR,OLD.SBS_SCOR_VAL);--
INSERT INTO RQ5.CNTRL_LST_ITM_ADNL_INFO_HIST(CNTRL_LST_ID,ITM_ ID,HIST_TMSTMP,ADNL_INFO_TYP,SEQ_ID, ADNL_INFO)
SELECT B.CNTRL_LST_ID,B.ITM_ID,CURRENT TIMESTAMP,B.ADNL_INFO_TYP,B.SEQ_ID,B.ADNL_INFO
FROM RQ5.CNTRL_LST_ITM_ADNL_INFO B WHERE B.CNTRL_LST_ID = OLD.CNTRL_LST_ID AND B.ITM_ID = OLD.ITM_ID;--
INSERT INTO RQ5.CNTRL_LST_ITM_SRC_HIST(CNTRL_LST_ID,ITM_ID,HIS T_TMSTMP,SRC_ID,SRC_NM_EN,SRC_NM_FR)
SELECT B.CNTRL_LST_ID,B.ITM_ID,CURRENT TIMESTAMP,B.SRC_ID,D.SRC_NM_EN,D.SRC_NM_FR
FROM RQ5.CNTRL_LST_ITM_SRC B INNER JOIN RQ5.SRC D ON B.SRC_ID = D.SRC_ID
WHERE B.CNTRL_LST_ID = OLD.CNTRL_LST_ID AND B.ITM_ID = OLD.ITM_ID;--
END

So far I know this symbol is being used in PL/SQL to comment out a line, but What is the siginficant of this symbol in trigger.

Thanks
Surjya
Reply With Quote
  #2 (permalink)  
Old 04-15-10, 14:49
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Anything after it on the same line is considered a comment and ignored.

Andy
Reply With Quote
  #3 (permalink)  
Old 04-15-10, 17:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The comment is a trick so that DB2 will not interpret the ';' as statement terminator. Otherwise, if you us ';' as statement terminator, the nested ';' would be interpreted as the terminator for the CREATE TRIGGER statement and the statement would obviously fail with a syntax error.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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