创建 Firebird 存储过程时出现错误 -104

发布于 2024-10-18 14:37:11 字数 724 浏览 2 评论 0原文

我无法运行以下 SP

CREATE PROCEDURE SP_NYANSAT(
        FORNAVN VARCHAR(30),
        EFTERNAVN VARCHAR(30),
        ADRESSE VARCHAR(50),
        POSTNUMMER CHAR(4),
        TELEFONNUMMER CHAR(8),
        EMAIL VARCHAR(50))
    AS
    DECLARE VARIABLE ID INTEGER;
    BEGIN
      ID = GEN_ID(GEN_ANSAT_ID,1);
      INSERT INTO MYTABLE (ID, FORNAVN, EFTERNAVN, ADRESSE, POSTNUMMER, TELEFONNUMMER, EMAIL) VALUES (:ID, :FORNAVN, :EFTERNAVN, :ADRESSE, :POSTNUMMER, :TELEFONNUMMER, :EMAIL);
    END

我收到的错误如下:

can't format message 13:896 -- message file C:\Windows\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, column 1.
CREATE.

I cannot run the following SP

CREATE PROCEDURE SP_NYANSAT(
        FORNAVN VARCHAR(30),
        EFTERNAVN VARCHAR(30),
        ADRESSE VARCHAR(50),
        POSTNUMMER CHAR(4),
        TELEFONNUMMER CHAR(8),
        EMAIL VARCHAR(50))
    AS
    DECLARE VARIABLE ID INTEGER;
    BEGIN
      ID = GEN_ID(GEN_ANSAT_ID,1);
      INSERT INTO MYTABLE (ID, FORNAVN, EFTERNAVN, ADRESSE, POSTNUMMER, TELEFONNUMMER, EMAIL) VALUES (:ID, :FORNAVN, :EFTERNAVN, :ADRESSE, :POSTNUMMER, :TELEFONNUMMER, :EMAIL);
    END

The error I get is the following:

can't format message 13:896 -- message file C:\Windows\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, column 1.
CREATE.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咽泪装欢 2024-10-25 14:37:11

您在这段代码之前和之后使用过 Set Term 吗?

Firebird 中的所有命令都必须以分号终止。如果要创建存储过程,则需要能够区分终止分号和存储过程内部的分号。

像这样:

SET TERM ^ ;

CREATE PROCEDURE SP_NYANSAT(
        FORNAVN VARCHAR(30),
        EFTERNAVN VARCHAR(30),
        ADRESSE VARCHAR(50),
        POSTNUMMER CHAR(4),
        TELEFONNUMMER CHAR(8),
        EMAIL VARCHAR(50))
    AS
    DECLARE VARIABLE ID INTEGER;
    BEGIN
      ID = GEN_ID(GEN_ANSAT_ID,1);
      INSERT INTO MYTABLE (ID, FORNAVN, EFTERNAVN, ADRESSE, POSTNUMMER, TELEFONNUMMER, EMAIL) VALUES (:ID, :FORNAVN, :EFTERNAVN, :ADRESSE, :POSTNUMMER, :TELEFONNUMMER, :EMAIL);
    END
    ^

SET TERM ; ^ 

请注意存储过程的声明如何以 ^ 终止,从而结束该语句。声明后,您还可以恢复终止分号。

附带说明一下,我建议将 firebird.msg 复制到您收到的错误告诉您的位置,以便您可以看到到底发生了什么。

编辑:

如果您愿意,可以查看此链接。在那里您可以找到大量有关 Firebird + IBExpress 的信息,包括 SET TERM(第 81 页)。

编辑2:

刚刚在家尝试使用IBExperts + Firebird,创建存储过程没有任何问题。我的猜测是您正在尝试执行以下操作之一:

  • 您已打开 SQL 编辑器并尝试直接编译代码。这是行不通的,因为 IBExperts 认为您正在尝试运行 DSQL 语句。存储过程是使用 PSQL 语句创建的。

  • 您正在尝试使用“新过程”实用程序(检查主菜单右上角的按钮)并将整个代码粘贴到编辑器中。这是行不通的,因为在该编辑器中您只需输入正文代码。存储过程名称在您打开的窗口右上角的字段中设置。参数和变量是通过使用代码编辑器上方左侧的“插入参数/变量”按钮引入的。 SET TERM 句子由 IBExperts 自动创建。您可以在 DDL 选项卡中检查生成的代码。

华泰

Have you used Set Term before and after this code?

All commands in Firebird must be terminated with a semi-colon. If you want to create a stored procedure you need to be able to distinguish between the terminating semi-colon from the semi-colons inside the stored procedure.

Something like this:

SET TERM ^ ;

CREATE PROCEDURE SP_NYANSAT(
        FORNAVN VARCHAR(30),
        EFTERNAVN VARCHAR(30),
        ADRESSE VARCHAR(50),
        POSTNUMMER CHAR(4),
        TELEFONNUMMER CHAR(8),
        EMAIL VARCHAR(50))
    AS
    DECLARE VARIABLE ID INTEGER;
    BEGIN
      ID = GEN_ID(GEN_ANSAT_ID,1);
      INSERT INTO MYTABLE (ID, FORNAVN, EFTERNAVN, ADRESSE, POSTNUMMER, TELEFONNUMMER, EMAIL) VALUES (:ID, :FORNAVN, :EFTERNAVN, :ADRESSE, :POSTNUMMER, :TELEFONNUMMER, :EMAIL);
    END
    ^

SET TERM ; ^ 

Please notice how the declaration of the stored procedure is terminated with ^, thus ending the statement. After the declaration you also restore the terminating semi-colon.

On a side note, I would recommend to copy firebird.msg to the location the error you get tells you so you can see what is really happening.

EDIT:

If you wish you can check this link. There you can find a lot of information regarding Firebird + IBExpress, including SET TERM (page 81).

EDIT 2:

Just tried at home with IBExperts + Firebird and I had no problem creating the stored procedure. My guess is you are trying to do one of the following things:

  • You have opened an SQL editor and are trying to compile the code directly. That will not work because IBExperts thinks you are trying to run DSQL sentences. Stored procedures are created with PSQL sentences.

  • You are trying to use the "New procedure" utility (check buttons in the upper right side of the main menu) and pasted the whole code into the editor. That will not work because in that editor you only have to put the body code. Stored procedure name is set in a field on the upper right side of the window you opened. Parameters and variables are introduced by using the "Insert Parameter/Variable" button on the left side above the code editor. The SET TERM sentences are created automatically by IBExperts. You can check the resulting code in the DDL tab.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文