IBM Support

create trigger extracted using db2look may fail with SQL0104N

Question & Answer


Question

Create trigger using the DDL extracted with db2look may fail with SQL0104N

Cause

The following is an example of the error received:

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 "END-OF-STATEMENT" was found following "imezone;
END IF".  Expected tokens may include:  "<psm_semicolon>".  LINE NUMBER=6.
SQLSTATE=42601

This is due to semicolon is used in trigger definition which caused conflict with the statement delimiter character. For example,

CREATE TRIGGER TSMDB1.IMBK_UPD_TRIGGER  BEFORE UPDATE ...
 FOR EACH ROW    BEGIN      IF ...
;
  END IF;    END;

Answer

You can change the statement delimiter. In the above example, you may change the last line of the DDL to :
END IF;    END@
Then issue : db2 -td@  -vf trigger.db2

Related Information

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"DB2 Tools - db2look","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.8;9.7;10.1;10.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21701103