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 > problem with trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-12, 03:00
dipankar.sarma30 dipankar.sarma30 is offline
Registered User
 
Join Date: Jul 2012
Posts: 9
problem with trigger

i have created a trigger and use this

referencing new_table as inserted;
begin
set "asd"=(select col1 from inserted);

end

error i am getting -

The definition of trigger "name" includes an invalid use of correlation name or transition table name "INSERTED". Reason code="4".. SQLCODE=-696, SQLSTATE=42898, DRIVER=3.63.108
Reply With Quote
  #2 (permalink)  
Old 07-14-12, 03:23
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,752
Please see manuals

SQL0696N
Code:
Explanation

The trigger definition included an invalid use of name.
 The value of reason-code identifies the roblem:

...
...
...

4
OLD TABLE name and NEW TABLE name are not allowed in a trigger
 if the trigger is defined using a compound SQL (compiled) statement.

The statement cannot be processed.

...
Anyway,
why do you want to use "NEW TABLE" instead of "NEW"?
Reply With Quote
  #3 (permalink)  
Old 07-14-12, 03:26
dipankar.sarma30 dipankar.sarma30 is offline
Registered User
 
Join Date: Jul 2012
Posts: 9
hi

i am using ibm data studio.
when i use begin atomic instead of begin then i am getting this error


An unexpected token "set "asd" = (select "col1" from" was found following "ey" decimal(16,0)". Expected tokens may include: "
".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.63.108
Reply With Quote
  #4 (permalink)  
Old 07-14-12, 03:38
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,752
Please publish your DB2 version/release/fixpack and platform OS
and whole of your CREATE TRIGGER statement(and CREATE TABLE statement, if necessary).
Reply With Quote
  #5 (permalink)  
Old 07-14-12, 03:46
dipankar.sarma30 dipankar.sarma30 is offline
Registered User
 
Join Date: Jul 2012
Posts: 9
hi

version is 9.7v and os is windows 7
sorry cant share the code because it is confidential.
Reply With Quote
  #6 (permalink)  
Old 07-14-12, 19:49
papadi papadi is offline
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 483
Quote:
sorry cant share the code because it is confidential.
Data is often confidential - meta-data, maybe not so much.

Even so, change the "confidential" stuff to something generic, try that, and post anything that is a surprise or unwanted.
Reply With Quote
  #7 (permalink)  
Old 07-14-12, 20:26
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,752
Root cause of a syntax error(SQLCODE=-104) was sometimes laid in earlier than the phrase reported by error message.
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