Page 1 of 1

TZQuery Invalid token "STATUS" apostrophe

Posted: 21.05.2024, 18:31
by JoeDelphi
I'm using TZQuery and when inserting a new record my database Field "STATUS" is in apostrophe und Firebird is getting following error:

Dynamic SQL ErrorSQL error code = -104 Token unknown - line 1, column 55 "STATUS". Error Code: -104. Invalid token The SQL: INSERT INTO AUFTRAGPOS (OID,AUFTRAG_NR,POS,ARTIKEL_KZ,"STATUS",TEXT1,

Anybody some hints for me

Greetings
Joe

Re: TZQuery Invalid token "STATUS" apostrophe

Posted: 22.05.2024, 14:56
by aehimself
This is a very unusual field name, I thought it's not possible to have special characters in field names.
Though I never worked with Firebird until now, escape works like \" or "" in other systems, so I'd try that first hand.

INSERT INTO xx VALUES (\"STATUS\", [...]
or
INSERT INTO xx VALUES (""STATUS"", [...]

Re: TZQuery Invalid token "STATUS" apostrophe

Posted: 22.05.2024, 16:48
by JoeDelphi
In TZQuery the insert statement is auto-generated, how can i manipulate this ? I even don't know, why this " is auto-generated only for my "STATUS" field. Seems mysterious to me...

(all other fields don't have this apostrophe, only my "STATUS" Field ... i think nothing special about the name of this field.)

Re: TZQuery Invalid token "STATUS" apostrophe

Posted: 22.05.2024, 20:28
by aehimself
Ah, I thought you are using TZQuery to run your INSERT query; my bad.

First, simply try to alias the field in your query... SELECT \"STATUS\" "STATUS" should get rid of the quotations.
An other thing is you can use TZUpdateSQL to specify the correct query to be executed.

Re: TZQuery Invalid token "STATUS" apostrophe

Posted: 24.05.2024, 08:22
by marsupilami
Hello Joe,

this really is strange.
JoeDelphi wrote: 22.05.2024, 16:48 In TZQuery the insert statement is auto-generated, how can i manipulate this ? I even don't know, why this " is auto-generated only for my "STATUS" field. Seems mysterious to me...
You could use TZUpdateSQL to provide your own statements, so Zeos doesn't auto generate its own statements. This would hide the problem.
JoeDelphi wrote: 22.05.2024, 16:48 (all other fields don't have this apostrophe, only my "STATUS" Field ... i think nothing special about the name of this field.)
Zeos quotes fields when it thinks the need quoting. Either whn it thinks they are reserved words or when it thinks that the case of the field name does require quoting.

Could you maybe try to generate a small sample that reproduces the problem? I tried to reproduce it using the following definition:
  • Field Name: ID, Data Type: INTEGER, no nulls allowed
  • Field Name: STATUS, Data Type: VARCHAR, 25
Unfortunately Sourceforge doesn't allow to write the full creating statement.

Then I used a Zeos based applilcation to manipulate data using a DBGrid and DBNavigator. Adding and manipulating data worked fine for me and I couldn't recreate your problem.

So - if you could provide a small sample (program + create script + data) that recreates the problem that would help a lot in debugging the problem.

Best regards,

Jan

My test environment:
  • Zeos 8.0-patches in the latest revision from SVN
  • Delphi 12
  • Firebird Embedded 3.0.7