Subject Re: IBO and FB 1
Author kittikira
--- In IBObjects@y..., Lucas Franzen <luc@r...> wrote:
>
> So the problem seems to be the table alias.
>
>
>
> Anyone else out there having a similar problem - and even better any
> solution?

Hello Lucas,

I also have the same problem. It is a new "feature" in Firebird 1
final release from March 12th.
In this release it seems that it is not allowed to qualify attributes
with an tablealias when it is not necessary, but IBO always qualifies
in the insertsql.
I did a workaround for myself which seems to work at the moment.
I made the following changes to the unit ibo_updatesql.

Sourcefile ibo_updatesql.imp

function TIB_UpdateSQL.GetInsertDSQL: TIB_Statement;
var
jj, kk: smallint;
ss, tt: string;
tmpPrm: TIB_Column;
begin
if CheckDSQLNeedsInit( FInsertDSQL ) then
begin
if InsertSQL.Count > 0 then
PrepareCustomDML( FInsertDSQL, FInsertSQL.Text )
else
begin
CheckKeyRelation;
kk := 0;
ss := '';
tt := '';
for jj := 0 to Dataset.FieldCount - 1 do
begin
if not Dataset.Fields[jj].ReadOnly and
not Dataset.Fields[jj].Computed and
( Dataset.SysKeyRelation = Dataset.Fields[jj].RelName )
then
// I changed the following code
{
begin
if kk > 0 then
begin
ss := ss + #13#10', ' + Dataset.Fields[jj].ReLName + '.' +
Dataset.Fields[jj].SQLName;
tt := tt + #13#10', ' + Dataset.ParamChar +
Dataset.Fields[jj].FullFieldName;
end else
begin
ss := ss + #13#10'( ' + Dataset.Fields[jj].ReLName + '.' +
Dataset.Fields[jj].SQLName;
tt := tt + #13#10'( ' + Dataset.ParamChar +
Dataset.Fields[jj].FullFieldName;
end;
Inc( kk );
end;
}
// to this code
begin
if kk > 0 then
begin
ss := ss + #13#10', ' + Dataset.Fields[jj].SQLName;
tt := tt + #13#10', ' + Dataset.ParamChar +
Dataset.Fields[jj].FullFieldName;
end else
begin
ss := ss + #13#10'( ' + Dataset.Fields[jj].SQLName;
tt := tt + #13#10'( ' + Dataset.ParamChar +
Dataset.Fields[jj].FullFieldName;
end;
Inc( kk );
end;
// end of changes
end;
if kk > 0 then
begin
ss := ss + ')'#13#10;
tt := tt + ')';
FInsertDSQL.SQL.Text := 'INSERT INTO ' +
Dataset.SysKeyRelation + ss +
'VALUES ' + tt;
FInsertDSQL.FCombineDuplicateParams := false;
FInsertDSQL.Prepare;
try
if ( kk = FInsertDSQL.ParamCount ) then
begin
kk := 0;
for jj := 0 to Dataset.FieldCount - 1 do
with Dataset.Fields[jj] do
if not ReadOnly and
not Computed and
( Dataset.SysKeyRelation = RelName ) then
begin
FInsertDSQL.Params[kk].PSQLVAR^ := PSQLVAR^;
if not Odd( FInsertDSQL.Params
[kk].PSQLVAR^.SQLType ) then
Inc( FInsertDSQL.Params[kk].PSQLVAR^.SQLType );
Inc( kk );
end;
end
else
begin
for jj := 0 to FInsertDSQL.ParamCount - 1 do
with FInsertDSQL.Params[jj] do
begin
tmpPrm := Dataset.FieldByName( FullFieldName );
PSQLVAR^ := tmpPrm.PSQLVAR^;
if not Odd( PSQLVAR^.SQLType ) then
Inc( PSQLVAR^.SQLType );
end;
end;
except
FInsertDSQL.Unprepare;
raise;
end;
end;
end;
end;
Result := FInsertDSQL;
end;

//---------------------------------


Good luck.


cu
Helmut