Sql error code 104 token unknown

I have a script, below, in Ostendo (an ERP), which runs on a firebird database. The script is written in Pascal. It returns an error "Firebird SQL: error code -104, token unknown, ’13/04/2018′ at the line TMPQuery2.ExecQuery. I removed the reference text DATEWORKED = AND and it works fine. I have commented out all the other lines I tried in solving it — of which none worked.

Any ideas as to where I am going wrong? I have a feeling it is do to with date format. I have tried dd-mm-yyyy, yyyy-mm-dd (which is how it works from a OBDC through excel), dd/mm/yyyy (which is how it is displayed in ostendo).

1 Answer 1

From where did you get the idea that date literal in Firebird is represented in format like ? The legal formats to cast string data types to the DATE is listed at "Literal Formats" section in the "Conversion of Data Types" chapter.

Basically the yyyy-mm-dd format is right but it must be a simple string ie DATEWORKED = »’ + TSDateWorked + »’ when concatenating strings in pascal.

But instead of building the query as a string one should use parametrized queries. Parameters in SQL string are usually represented by name which has a colon in front of it, ie :DateWorked . So your query would look like

The query component usually also has ParamByName methods so that instead of parameter position you can assign values using the names. I don’t konw the TpFIBQuery component so the property/method names might differ, consult the help of the component.

create table groupp
(groupid numeric not null primary key,
nazv varchar(20),
kolvo numeric(2),
city varchar(15),
dataobr date(8));
commit;

Читайте также:  Asus p5k epu инструкция

Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown — line 6, char 8.
(.
все буквы английские.
если убрать (8) то ругается на commit;

Когда я запускаю эту команду через базу данных напрямую, она работает нормально, но внутри моего кода на C # эта ошибка сбрасывается.

3 ответа

Используйте ""VALUE"" с двойными кавычками, так как одна кавычка закроет вашу строку.

VALUE — это зарезервированное слово в Firebird, это означает, что его нельзя использовать в запросе в качестве имени объекта. Вам нужно либо использовать другое имя, либо явно указать его как "VALUE" , чтобы анализатор запросов знал, что это не зарезервированное слово.

Я пытаюсь создать таблицу в моей базе данных Interbase.

Ошибка динамического SQL Код ошибки SQL = -104 Неожиданный конец команды

Rate this post

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *