Question

I use IBDac with Delphi to connect to Firebir db and suddenly when I tried to run the software I got this error

Dynamic SQL ErrorSQL error code = -206 Column unknown table1.MyField_ID At line 6, column 18

the error show up when I try to open the dataset

mydataset.open;

the column exists of course. it is a foreign key to another table. I really dont know why I get this error !! here is the SQL I used in the component:

CREATE TABLE table1 (
      pkfield1 INTEGER NOT NULL,
      field_no INTEGER NOT NULL,
      fk1_id INTEGER NOT NULL,
      fk2_id INTEGER,
      MyField_ID INTEGER,
      bfield INTEGER);     

  select 
        table1.pkfield1,
        table1.field_no,
        table1.fk1_id,
        table1.fk2_id,
        table1.MyField_ID, <<<------- the field that cause the error
        table1.bfield,
        table2.desc1,
        table2.desc2,
        table2.desc3
    from table2
    right outer join table1 on (table2.pk1_id = table1.fk1_id)
    Order by table1.fk1_id, table1.field_no desc

Please advise

thanks

Was it helpful?

Solution

Change your case, as it looks like your database layer is automatically quoting it if you use CamelCase.

A quick test in a Firebird 2.5 database here shows:

SQL> select t1.usuario, t1.NoExisto from sg_usuario t1;
Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-T1.NOEXISTO
-At line 1, column 23


SQL> select t1.usuario, "t1.NoExisto" from sg_usuario t1;
Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-t1.NoExisto
-At line 1, column 34

As you see, the database engine generates an error with camel case only when it gets the SQL query using quotes.

I suggest you to try myfield_id or use the correct case you have in your field name.

    select 
        table1.pkfield1,
        table1.field_no,
        table1.fk1_id,
        table1.fk2_id,
        table1.myfield_id, 
        table1.bfield,
        table2.desc1,
        table2.desc2,
        table2.desc3
    from table2
    right outer table1 on (table2.pk1_id = table1.fk1_id)
    Order by table1.fk1_id, table1.field_no desc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top