在Firebird上执行脚本错误令牌未知 - 第1行,第5列TERM。错误代码:-104

时间:2015-02-05 09:41:51

标签: sql database firebird

我正在尝试编写一个创建表的脚本,添加一些约束,然后使列自动递增。据我所知,它发生在发生器和插入触发器之前。

这是我的代码:

CREATE TABLE BLANKS
(
 ID INT NOT NULL PRIMARY KEY,
 BLANK_ID INT NOT NULL,
 DATABASE_ID SMALLINT NOT NULL,
 BLANK_VERSION DECIMAL,

 CONSTRAINT ROW_UNIQUENESS UNIQUE(BLANK_ID, DATABASE_ID, BLANK_VERSION)
)


    /* Autoincrement for field (ID) */
    CREATE GENERATOR GEN_BLANKS_ID;

    SET TERM ^ ;

    CREATE TRIGGER BLANKS_BI FOR BLANKS
    ACTIVE BEFORE INSERT POSITION 0
    AS
    BEGIN
      IF (NEW.ID IS NULL) THEN
      NEW.ID = GEN_ID(GEN_BLANKS_ID,1);
    END^

    SET TERM ; ^

但它只是不起作用。它会创建表和生成器,但当它到达 SET TERM ^ ; 时,脚本会失败并显示错误:

SQL Error:  Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 5 TERM. Error Code: -104. can't format message 13:896 -- message file C:\Program Files (x86)\SQL Maestro Group\firebird.msg not found The SQL: SET TERM ^ ;
; 

你有什么建议吗?

1 个答案:

答案 0 :(得分:3)

在create table语句后添加分号,如果SQL客户端不喜欢,则删除set term ^语法:

CREATE TABLE BLANKS
(
 ID INT NOT NULL PRIMARY KEY,
 BLANK_ID INT NOT NULL,
 DATABASE_ID SMALLINT NOT NULL,
 BLANK_VERSION DECIMAL,

 CONSTRAINT ROW_UNIQUENESS UNIQUE(BLANK_ID, DATABASE_ID, BLANK_VERSION)
);


    /* Autoincrement for field (ID) */
    CREATE GENERATOR GEN_BLANKS_ID;

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