Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    3

    Question Unanswered: Trigger with BEGIN ATOMIC and @ terminator

    Hi ppl,

    I'm trying to condense two trigger statements into one because i thought it was possible. I've read a few previous posts but still can't get it to work: (I don't seem to be very good with triggers in DB2!)
    Code:
    CREATE TRIGGER order_update
    AFTER INSERT ON order
    REFERENCING NEW AS new
    FOR EACH ROW MODE DB2SQL
    
    BEGIN ATOMIC
    
    UPDATE customer 
    SET balance_owed = balance_owed + (qty*(SELECT price FROM book b, customer c  WHERE new.cno = c.cno AND new.bno = b.bno))
    WHERE new.cno = c.cno;
    
    UPDATE book b
    SET sales = sales + new.qty
    WHERE new.bno = b.bno;
    
    END@
    I have set TOOLS>TOOLS SETTINGS \ USE STATEMENT TERMINATION CHARACTER to @

    but using this code i get the following error -

    An unexpected token "END-OF-STATEMENT" was found following "HERE
    new.cno = c.cno". Expected tokens may include: "<interval_qualifier>".
    SQLSTATE=42601

    and have no idea what it means / how to solve it.

    Any help appreciated,
    Cheers,

    Jim

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Trigger with BEGIN ATOMIC and @ terminator

    I have never been successful in understanding Command Centre ...

    So, I put them in a flat-file and run it from command line ...

    Copy the trigger text to a file and name it , say C:\trigger.sql

    Open DOS prompt, type in db2cmd ... In the new window, navigate to C:\ and then
    db2 -td@ -f trigger.sql

    td@ tells db2 to use @ as the delimiter

    HTH

    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •