DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old June 2nd, 2006, 12:06 PM
Dipesh Dipesh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 29 Dipesh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 51 sec
Reputation Power: 0
Trigger compilation error

Hi,

I am creating a trigger in DB2 express version.

When i use the following syntax to create trigger

CREATE TRIGGER USER_PK_TRIGGER
BEFORE INSERT On users
REFERENCING NEW As N
FOR EACH ROW
Begin
if((N.user_id is null) or (N.user_id <= 0)) then
set N.user_id = nextval for user_seq;
end if;
End@


I am getting the following error.

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 "(" was found following "EACH ROW Begin if(".
Expected tokens may include: "<space>". LINE NUMBER=6. SQLSTATE=42601

But when i change my create trigger syntax to include atomic word it works.

CREATE TRIGGER USER_PK_TRIGGER
BEFORE INSERT On users
REFERENCING NEW As N
FOR EACH ROW
Begin Atomic
if((N.user_id is null) or (N.user_id <= 0)) then
set N.user_id = nextval for user_seq;
end if;
End@

Why do i need to make my trigger atomic? When it commits does it commit everything (in the ongoing transaction) or only the compound statement in the trigger? What is wrong in my first create trigger syntax?

I am new in DB2 and in most of the examples they have shown that something like first syntax should work, i am not able to figure what what is wrong here. Any help to fix this will be highly appreciated.

Thanks in advance.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Trigger compilation error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway