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

I get this error while creating the trigger below:

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 

Where am I missing? I already have my table ID created with a primary id oid, that must be auto incremented. I also created my generator function MY_GEN_ID.

alyssaeliyah
  • 1,684
  • 3
  • 24
  • 62

1 Answers1

1

You have to set the statement terminator and use it to terminate the CREATE TRIGGER statement, ie

SET TERM ^;

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

SET TERM ;^
ain
  • 21,481
  • 3
  • 47
  • 70