开发者

Error -104 creating Firebird stored procedure

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 -- mess开发者_如何学编程age file C:\Windows\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, column 1.
CREATE.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜