Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    SWEDEN
    Posts
    10

    Unanswered: Trigger problem, OS-390/DB2 v7

    Hej
    Trigger problem.
    OS-390/DB2 v7

    (GiltigFom and GiltigTom IS NULL)
    When the trigger below is executed it is only the first CASE that is SET.
    -----------
    DROP TRIGGER TR_INSTAANST

    CREATE TRIGGER tr_insTAAnst NO CASCADE BEFORE INSERT ON TAAnst
    REFERENCING NEW as NEW_VAR
    FOR EACH ROW MODE DB2SQL
    WHEN (NEW_VAR.A06_GiltigFom IS NULL OR NEW_VAR.A06_GiltigTom IS NULL)
    BEGIN ATOMIC
    SET NEW_VAR.A06_GiltigFom =
    CASE
    WHEN NEW_VAR.A06_GiltigFom IS NULL THEN CURRENT DATE
    END,
    NEW_VAR.A06_GiltigTom =
    CASE
    WHEN NEW_VAR.A06_GiltigTom IS NULL THEN '2999-12-31'
    END;
    END
    --------------

    Any help would be appreciated.
    /uffe

  2. #2
    Join Date
    Aug 2003
    Location
    Massachusetts, USA
    Posts
    106

    Re: Trigger problem, OS-390/DB2 v7

    Try specifying ELSE NEW_VAR.A06_GiltigTom (Fom) after the THEN in each CASE statement.


    CREATE TRIGGER tr_insTAAnst NO CASCADE BEFORE INSERT ON TAAnst
    REFERENCING NEW as NEW_VAR
    FOR EACH ROW MODE DB2SQL
    WHEN (NEW_VAR.A06_GiltigFom IS NULL OR NEW_VAR.A06_GiltigTom IS NULL)
    BEGIN ATOMIC
    SET NEW_VAR.A06_GiltigFom =
    CASE
    WHEN NEW_VAR.A06_GiltigFom IS NULL THEN CURRENT DATE ELSE NEW_VAR.A06_GiltigFom END,
    NEW_VAR.A06_GiltigTom =
    CASE
    WHEN NEW_VAR.A06_GiltigTom IS NULL THEN '2999-12-31' ELSE NEW_VAR.A06_GiltigTom
    END;
    END
    --------------

    Any help would be appreciated.
    /uffe [/SIZE][/QUOTE]

  3. #3
    Join Date
    May 2003
    Location
    SWEDEN
    Posts
    10

    Re: Trigger problem, OS-390/DB2 v7

    Originally posted by dmmac
    Try specifying ELSE NEW_VAR.A06_GiltigTom (Fom) after the THEN in each CASE statement.


    CREATE TRIGGER tr_insTAAnst NO CASCADE BEFORE INSERT ON TAAnst
    REFERENCING NEW as NEW_VAR
    FOR EACH ROW MODE DB2SQL
    WHEN (NEW_VAR.A06_GiltigFom IS NULL OR NEW_VAR.A06_GiltigTom IS NULL)
    BEGIN ATOMIC
    SET NEW_VAR.A06_GiltigFom =
    CASE
    WHEN NEW_VAR.A06_GiltigFom IS NULL THEN CURRENT DATE ELSE NEW_VAR.A06_GiltigFom END,
    NEW_VAR.A06_GiltigTom =
    CASE
    WHEN NEW_VAR.A06_GiltigTom IS NULL THEN '2999-12-31' ELSE NEW_VAR.A06_GiltigTom
    END;
    END
    --------------

    Any help would be appreciated.
    /uffe
    [/SIZE][/QUOTE]

  4. #4
    Join Date
    May 2003
    Location
    SWEDEN
    Posts
    10

    Re: Trigger problem, OS-390/DB2 v7

    Hej dmmac,
    Thanks for that!!!
    /uffe

    Originally posted by dmmac
    Try specifying ELSE NEW_VAR.A06_GiltigTom (Fom) after the THEN in each CASE statement.


    CREATE TRIGGER tr_insTAAnst NO CASCADE BEFORE INSERT ON TAAnst
    REFERENCING NEW as NEW_VAR
    FOR EACH ROW MODE DB2SQL
    WHEN (NEW_VAR.A06_GiltigFom IS NULL OR NEW_VAR.A06_GiltigTom IS NULL)
    BEGIN ATOMIC
    SET NEW_VAR.A06_GiltigFom =
    CASE
    WHEN NEW_VAR.A06_GiltigFom IS NULL THEN CURRENT DATE ELSE NEW_VAR.A06_GiltigFom END,
    NEW_VAR.A06_GiltigTom =
    CASE
    WHEN NEW_VAR.A06_GiltigTom IS NULL THEN '2999-12-31' ELSE NEW_VAR.A06_GiltigTom
    END;
    END
    --------------

    Any help would be appreciated.
    /uffe
    [/SIZE][/QUOTE]

Posting Permissions

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