1
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

4

1 回答 1

1

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

SET TERM ^;

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

SET TERM ;^
于 2015-07-20T05:32:48.037 回答