Subject | RE: [firebird-support] Dynamic SQL Error SQL error code = -104. Unexpected end of command - line 7, column 47 |
---|---|
Author | Arnold Levy |
Post date | 2014-06-10T16:20:02Z |
Dear Svein,
Thank you very much for your SET TERM suggestion! I implemented it and it worked like a charm!
I would also like to thank Mark for checking the CREATE TABLE part of the script in isolation - something that I didn't even consider myself - as I needed the GENERATOR integral to the script.
I suspect that the parser of Firebird SQL was written as a recursive decent implementation - judging from the poor error reporting. I heard that Firebird is written in C. A great LR grammar parser such as Hyacc - also written in C - which is an improvement on Bison - the original yacc is available. I believe that Hyacc would comfortably handle the Firebird/Interbase SQL grammar. Why this suggestion? - because accurate error reporting can be provided by using such an implementation of the parser.
Thanks once again to both Svein and Mark.
With Blessings to all...
Sincerely,
Arnold.
On 10 Jun 2014 12:19, "Svein Erling Tysvær svein.erling.tysvaer@... [firebird-support]" <firebird-support@yahoogroups.com> wrote:
>Everything seems to be properly formed - can anyone cast some light on what I am missing here?
Sure, the problem is not in create table, but in the trigger - you need SET TERM since you cannot use ; inside the trigger if it is also the terminator:
CREATE TABLE "Administrators" (
"_Id" INTEGER NOT NULL,
"_MyDetailId" INTEGER DEFAULT 0,
"_Name" VARCHAR(50),
"_Designation" VARCHAR(50),
"_Address" BLOB SUB_TYPE TEXT SEGMENT SIZE 255 CHARACTER SET ASCII,
"_Emails" BLOB SUB_TYPE TEXT SEGMENT SIZE 255 CHARACTER SET ASCII,
"_TelephoneNumbers" BLOB SUB_TYPE TEXT SEGMENT SIZE 255 CHARACTER SET ASCII,
"_Reference" VARCHAR(50)
);
ALTER TABLE "Administrators" ADD CONSTRAINT "PrimaryKey" PRIMARY KEY ("_Id");
CREATE INDEX "_Id" ON "Administrators"("_Id");
CREATE INDEX "_MyDetailId" ON "Administrators"("_MyDetailId");
CREATE GENERATOR "GEN_Administrators__Id";
SET TERM ^^ ;
CREATE TRIGGER "TR_AI_Administrators__Id" FOR "Administrators"
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
IF (NEW."_Id" IS NULL) THEN
NEW."_Id" = GEN_ID("GEN_Administrators__Id", 1);
END ^^
SET TERM ; ^^
HTH,
Set