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 > Trouble executing sql file from script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 01-21-08, 17:50
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Great thanks for your help. It worked for some reason. But it's failing on the last sql file. Here's the error message:

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0778N End label "@" is not the same as the begin label. LINE NUMBER=8.
SQLSTATE=428D5

Here is my db2 call: db2 -td@ -f rqprojlock_insert.sql

Here's my sql:

CREATE TRIGGER RQPROJLOCK_INSERT
AFTER INSERT ON RqProjects
REFERENCING NEW AS new_row
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
INSERT INTO RqProjectLocks (ID) VALUES (new_row.ID);
END
@

Thanks again.
Reply With Quote
  #17 (permalink)  
Old 01-22-08, 02:30
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by rev1976
The script runs fine but when i check the out file that's where the error message is. When i logon to DB2 and do LIST TABLES i don't see any of the tables that were suppose to be created.
That's to be expected: without COMMITs, the CREATEs are rolled back after the last erroneous statement.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #18 (permalink)  
Old 01-22-08, 02:33
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by rev1976
Code:
CREATE TRIGGER RQPROJLOCK_INSERT 
AFTER INSERT ON RqProjects
REFERENCING NEW AS new_row
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
   INSERT INTO RqProjectLocks (ID) VALUES (new_row.ID);
END
@
Why not just remove the "@" ?
Or remove the "BEGIN ATOMIC" & "END", since it's just a single statement?
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #19 (permalink)  
Old 01-22-08, 08:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by Peter.Vanroose
Why not just remove the "@" ?
Or remove the "BEGIN ATOMIC" & "END", since it's just a single statement?
The script probably has more than the one statement so the @ terminator is necessary. Yes for this trigger the BEGIN ATOMIC block is unnecessary, but it might be for another trigger. The syntax is correct, so I am guessing that the problem is not related to that. I have seen this error before and I have fixed it by adding "white space". Add a space after the END of the BEGIN ATOMIC and if that does not work, add a space at the end of every line in the trigger.

HTH

Andy
Reply With Quote
  #20 (permalink)  
Old 01-22-08, 09:28
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Thanks for all your help. I manually ran the sql in DB2 to create the trigger. Thanks again.
Reply With Quote
  #21 (permalink)  
Old 06-28-09, 16:31
gango gango is offline
Registered User
 
Join Date: Jan 2007
Posts: 4
Quote:
Originally Posted by rev1976
Great thanks for your help. It worked for some reason. But it's failing on the last sql file. Here's the error message:

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0778N End label "@" is not the same as the begin label. LINE NUMBER=8.
SQLSTATE=428D5

Here is my db2 call: db2 -td@ -f rqprojlock_insert.sql

Here's my sql:

CREATE TRIGGER RQPROJLOCK_INSERT
AFTER INSERT ON RqProjects
REFERENCING NEW AS new_row
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
INSERT INTO RqProjectLocks (ID) VALUES (new_row.ID);
END
@

Thanks again.

You just need to press ENTER at the end of each delimeter (@) character. Ensure tht here delimiter should always be followed by a carriage return character i.e ENTER"

Thanks and Regards,
GANESH GOSAVI
IBM
Reply With Quote
  #22 (permalink)  
Old 02-03-12, 17:03
kschust kschust is offline
Registered User
 
Join Date: Feb 2012
Posts: 1
Thought I'd post the solution that worked for me, in case it might help someone else.

I, too, was passing an input file. Create failed with the same error (SQL0778N). Resolved it by adding a "begin label" before the BEGIN ATOMIC statement, i.e.

CREATE TRIGGER RQPROJLOCK_INSERT
AFTER INSERT ON RqProjects
REFERENCING NEW AS new_row
FOR EACH ROW MODE DB2SQL
@: BEGIN ATOMIC
INSERT INTO RqProjectLocks (ID) VALUES (new_row.ID);
END
@
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