Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    3

    Unanswered: How to create an empty trigger

    I need to create an empty Trigger Or a Trigger which has only comments
    in it.
    I tried this but it does not get created ....Gives Trigger creation
    errors.

    This is what I tried :
    ----------

    create trigger e_trig after INSERT on c
    REFERENCING NEW AS NEW for each row mode db2sql
    -- This is a Dummy Trigger
    @

    [IBM][CLI Driver][DB2] SQL0969N There is no message text
    corresponding to SQL error "-20100" in the message file on this
    workstation. The error was returned from module "DSNHPARS" with
    original tokens "2 -104 42601 -,( END SET CALL DROP FREE HOLD LOCK
    OPEN PARM ALTER BEGI". SQLSTATE=56059

    Execution Failed!
    ----------

    Also tried this
    --------
    create trigger tI_d1 after INSERT on d
    REFERENCING NEW AS NEW for each row mode db2sql
    BEGIN ATOMIC
    -- comments go here
    END@

    [IBM][CLI Driver][DB2] SQL0104N An unexpected token "END" was found
    following "". Expected tokens may include: ";". SQLSTATE=42601

    Execution Failed!
    ----------

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Why not try something like this:

    create trigger tI_d1 after INSERT on d
    REFERENCING NEW AS NEW for each row mode db2sql
    BEGIN ATOMIC
    -- comments go here
    DECLARE x int;

    SET x = 1;
    END@

    Andy

  3. #3
    Join Date
    Sep 2003
    Posts
    3
    That did not work. I am using db2/390 7. I am getting the following err.

    ----------
    create trigger tI_d1 after INSERT on d
    REFERENCING NEW AS NEW for each row mode db2sql
    BEGIN ATOMIC
    -- comments go here
    DECLARE x int;

    SET x = 1;
    END


    [IBM][CLI Driver][DB2] SQL0969N There is no message text corresponding to SQL error "-20100" in the message file on this workstation. The error was returned from module "DSNHPARS" with original tokens "2 -104 42601 -,( END SET CALL DROP FREE HOLD LOCK OPEN PARM ALTER BEGI". SQLSTATE=56059

    Execution Failed!
    -------------

    I know in case of ORACLE we need to add "NULL;" in the trigger body for it to compile/create a valid trigger. Is therse anything similar for DB2. I actually dont want to put Declare statements...instead just some comments stating that this trigger is for future use and can be modified latter.

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Sorry, I cannot help you with OS/390.

    Andy

  5. #5
    Join Date
    Sep 2003
    Posts
    3
    I tried this on DB2/UDB 7.1 but no success.

    ------------
    create trigger tI_d1 after INSERT on a
    REFERENCING NEW AS NEW for each row mode db2sql
    BEGIN ATOMIC
    -- comments go here
    DECLARE x int;

    SET x = 1;
    END


    [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "ATOMIC" was found following "w mode db2sql BEGIN". Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601

    Execution Failed!
    ------

    What version of DB2 did you test this on? What am I missing here?

    -Smitesh

  6. #6
    Join Date
    Sep 2003
    Location
    Colombo, Sri Lanka
    Posts
    63
    I think the problem is that the trigger is an after insert. Try to make is a before insert and see whether it works.

  7. #7
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Rather, I suspect it is because of the differences in coding triggers for LUW and OS/390 db2s

    Cheers

    Sathyaram

    Originally posted by tm_suren
    I think the problem is that the trigger is an after insert. Try to make is a before insert and see whether it works.
    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
  •