Results 1 to 2 of 2
  1. #1
    Join Date
    May 2015
    Posts
    4

    Unanswered: DB2 Trigger error

    Hi,

    I am getting the below error on my db2 trigger. Can you please help me understand what this error is and how to fix it?

    Trigger:

    CREATE TRIGGER SCS.B_TRIG_INSERT_STORE_CONFIG AFTER INSERT OR UPDATE ON SCS.B_L2B_CONFIG REFERENCING NEW AS i NEW_TABLE AS n FOR EACH ROW MODE DB2SQL
    BEGIN ATOMIC
    DECLARE v_build_num VARCHAR(10);
    DECLARE v_consolidated_count INTEGER DEFAULT 0;

    SET v_build_num = substr(i.BUILD_NUM,1,locate('-',i.BUILD_NUM)-1);

    SELECT 1 into v_consolidated_count
    FROM SCS.B_STORE_CONFIG
    WHERE STORE_NUM = i.STORE_NUM AND
    CONFIG_NAME = 'ConsolidatedSecurity';

    IF ( v_consolidated_count = 0 ) THEN
    IF CAST(v_build_num AS INT) > 4589 THEN
    INSERT INTO SCS.B_STORE_CONFIG VALUES
    (i.STORE_NUM, 'ConsolidatedSecurity', 'Yes');
    END IF;
    END IF;

    END^
    CONNECT RESET^

    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 "v_consolidated_count" was found following
    ")-1); SELECT 1 into". Expected tokens may include: "<space>". LINE
    NUMBER=8. SQLSTATE=42601

    Thanks
    Anis GovindaRao

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    SQL0104N means a syntax error.
    I'm not sure if SELECT ... INTO is allowed in your trigger. Try changing it to
    SET v_consolidated_count = (SELECT ...)
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Posting Permissions

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