Subject Error in TIB_UpdateSQL with delimited tables?
Author Martijn Tonies
Hi all,

I've just had a customer reporting errors with a table name "CASE"
(yes, with quotes, it's a reserved word). From what I can see, I'm
using v4.3.Aa

When doing a simple:

select *
from "CASE"
order by PKfields

The following happens when modifying the value in a column:

function TIB_UpdateSQL.GetEditDSQL: TIB_Statement;
var
ii, jj: smallint;
edSQL: string;
begin
if CheckDSQLNeedsInit( FEditDSQL ) then
begin
if ModifySQL.Count > 0 then
PrepareCustomDML( FEditDSQL, FModifySQL.Text )
else
with Dataset do
begin
CheckKeyRelation;
edSQL := 'UPDATE ' + SysKeyRelation + #13#10;
jj := 0;
for ii := 0 to FieldCount - 1 do with Fields[ii] do
begin
if not ReadOnly and not Computed and ( SysKeyRelation =
RelName ) then

//// SysKeyRelation holds "CASE" while RelName holds CASE and as you
can see, they are not equal. This goes on for all columns, so in the
end, jj = 0 and the exception 'Cannot initialize EditDSQL' is being
raised.

begin
if jj = 0 then
edSQL := edSQL + ' SET ' + SQLName + ' = ' + ParamChar +
SQLName
else
edSQL := edSQL + #13#10' , ' +
SQLName + ' = ' +
ParamChar + SQLName;
Inc( jj );
end;
end;
if jj = 0 then begin
raise EIB_DatasetError.Create( Format(
E_Init_Default_SQL_Failed,
[ 'EditDSQL' ] ));
end;
edSQL := edSQL + #13#10'WHERE ';


Does it make sense to check like:
if ... (AnsiDequotedStr(SysKeyRelation) = RelName)

?


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL &
MS SQL Server
Upscene Productions
http://www.upscene.com