Subject Re: [IBO] "column not found"
Author Helen Borrie (TeamIBO)
At 12:00 AM 19-03-02 +0100, Duilio Foschi wrote:
>I am using D3 and IBO3.
>
> with TIBOQuery.Create(Self) do
> try
> databaseName:='cb4db';
> sql.Add('select');
> sql.Add('y_mov,');
> sql.Add('d_mov,');
> sql.Add('n_mov,');
> sql.Add('tip_doc,');
> sql.Add('n_doc,');
> sql.Add('d_doc,');
> sql.Add('note,');
> sql.Add('serie,');
> sql.Add('prezzo,');
> sql.Add('qta,');
> sql.Add('um,');
> sql.Add('cod_acc');
> sql.Add('from mv_hd, mv_dl, mv_li, mv_dg, art'); {1}
> Prepare;
> ...
> finally
> Free;
> end;
>
>When the Prepare command is executed, I get the error "column not found
>MV_HD".
>
>It seems that IBO changes the code above adding the following line to {1}
>
>mv_hd, mv_dl, mv_li, mv_dg, art.rdb$db_key
>
>Why does IBO do that and what's wrong with my code ?

We'll start with the second question first.

This is not a valid SQL statement. It is a SQL-89 JOIN statement but it is
missing (a) the join criteria and (b) the table identifiers from all of the
columns in the select list.

With IBO, even when you correct the SQL, using SQL-89 joins is not
recommended. You should use the SQL-92 syntax,
select a.col1, b.col2, c.col3
from atable a
join btable b on a.somecolumn = b.somecolumn
join ctable c on......

If you use the SQL-89 syntax, you need to provide JoinLinks for IBO to tell
it which columns in the WHERE clause are for joining.

Now, the second question: why is IBO doing what it is doing?

IBO is attempting (unsuccessfully) to parse an invalid statement. It has
included rdb_key in the select list because either a) there are no keylinks
supplied or b) the supplied keylinks are not valid; and probably the comma
following the name of the first table is causing the ISC error.

regards,
Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com