-1

I have the database table AllowedFields with the following columns:

ID int
Name Varchar(50)
FieldRecord Decimal(7,2)

I am trying to insert demo records using the following query:

set term ^ ;
EXECUTE BLOCK AS BEGIN
INSERT INTO AllowedFields(Name, FieldRecord) VALUES ("A", 0.00);
INSERT INTO AllowedFields(Name, FieldRecord) VALUES ("E", 13.00);
END^

But I am getting this error message:

Engine Code    : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -206
Column unknown
A
At line 3, column 37

Obviously firebird sees this A value as a column value?

How would I change this script to insert a record. Thanks.

3
  • Try using single quotes for string literals: 'A', and 'E'. Commented Jun 25, 2013 at 18:41
  • @mbeckish :) thanks, please post your comment as an answer, so I can accept it. Commented Jun 25, 2013 at 18:51
  • You can go ahead and give the credit to @a_horse_with_no_name. :) Commented Jun 25, 2013 at 19:39

1 Answer 1

1

The SQL standard defines double quotes to denote identifiers (table names, column names, constraint names, ...). So "A" identifies a column named A and not a single character.

String literals have to be enclosed in single quotes in SQL. So you need to use 'A' to denote a string (character) literal.

Putting this together you need:

INSERT INTO AllowedFields(Name, FieldRecord) VALUES ('A', 0.00);
INSERT INTO AllowedFields(Name, FieldRecord) VALUES ('E', 13.00);

You should also be aware that the standard requires quoted names to be case-sensitive, so "A" is a different column than "a").

And Firebird follows the standard.

Sign up to request clarification or add additional context in comments.

1 Comment

There is an exception: if you are using the legacy dialect 1 instead of dialect 3, then double quotes can be used to delimit strings. However dialect 1 should be considered deprecated since Interbase 6 / Firebird 1 (2000ish)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.