Patrick Moloney
Patrick Moloney

Reputation: 642

DDL Create Trigger script fails

A DDL script to create a trigger (source below) fails with 2 errors:

Statement failed, SQLSTATE = 42000 Dynamic SQL Error -SQL error code = -104 -Unexpected end of command - line 3, column 44 After line 0 in file C:\CRMDemo\Database\DDL\Trigger_Orders.sql Statement failed, SQLSTATE = 42000 Dynamic SQL Error -SQL error code = -104 -Token unknown - line 1, column 1 -end At line 14 in file C:\CRMDemo\Database\DDL\Trigger_Orders.sql

(line 3, column 44 looks like it may be the closing parthesis). I can't find any information about errors 42000 or -104. The trigger is designed to assign a record number from a generator, which does exist. This trigger works properly in Interbase from the same script. The only thing I can think of is that the column size, Integer, is incorrect for the value returned. But the documentation says the value may be truncated but should work for the expected value (1).

CREATE TRIGGER ORDERS_GENERATE_KEY FOR ORDERS ACTIVE BEFORE INSERT POSITION 95 AS
begin
  NEW.ORDER_NR = GEN_ID(NEW_ORDER_NUMBER, 1);
end;

Firebird is ver 2.5.2, just downloaded. Windows 7. Database should be 32bit.

Upvotes: 0

Views: 1903

Answers (1)

Andrej Kirejeŭ
Andrej Kirejeŭ

Reputation: 5481

If you run your statement using isql utility take sure that SET TERM operators are used:

SET TERM ^ ;

CREATE TRIGGER ORDERS_GENERATE_KEY FOR ORDERS 
  ACTIVE 
  BEFORE INSERT 
  POSITION 95 
AS
begin
  NEW.ORDER_NR = GEN_ID(NEW_ORDER_NUMBER, 1);
end
^

SET TERM ; ^

Upvotes: 3

Related Questions