创建触发器时的Firebird错误

时间:2015-07-20 03:43:35

标签: triggers generator firebird firebird2.1 flamerobin

Preparing query:     CREATE TRIGGER autoincrementor_id FOR ID
    ACTIVE BEFORE INSERT POSITION 0
    AS
    BEGIN
     IF (NEW.OID IS NULL) THEN
     NEW.OID = GEN_ID(MY_GEN_ID,1)
    Error: *** IBPP::SQLException ***
    Context: Statement::Prepare(     CREATE TRIGGER autoincrementor_id FOR ID
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.OID IS NULL) THEN
NEW.OID = GEN_ID(MY_GEN_ID,1) )
Message: isc_dsql_prepare failed

SQL Message : -104
Invalid token

Engine Code    : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Unexpected end of command - line 6, column 33

我在下面创建触发器时遇到此错误:

CREATE TRIGGER autoincrementor_id FOR ID
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.OID IS NULL) THEN
NEW.OID = GEN_ID(MY_GEN_ID,1);
END 

我错过了什么地方?我已经使用主ID ID创建了我的表oid,必须自动递增。我还创建了我的生成器函数MY_GEN_ID

1 个答案:

答案 0 :(得分:1)

您必须设置语句终止符并使用它来终止CREATE TRIGGER语句,即

SET TERM ^;

CREATE TRIGGER autoincrementor_id FOR ID
  ... rest of the trigger's body
END^

SET TERM ;^