TZQuery Invalid token "STATUS" apostrophe

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
JoeDelphi
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 19.05.2024, 10:07

TZQuery Invalid token "STATUS" apostrophe

Post 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
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZQuery Invalid token "STATUS" apostrophe

Post 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"", [...]
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
JoeDelphi
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 19.05.2024, 10:07

Re: TZQuery Invalid token "STATUS" apostrophe

Post 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.)
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZQuery Invalid token "STATUS" apostrophe

Post 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.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: TZQuery Invalid token "STATUS" apostrophe

Post 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
Post Reply