Board index » delphi » Cached updates with UpdateSQL

Cached updates with UpdateSQL

Can anyone give me a simple code example?
I keep getting "Operation not applicable".

Delphi 3, NT 4.0, BDE 4.51, Oracle 7.3 via ODBC

Bruce Swart (br...@cm.co.za)

 

Re:Cached updates with UpdateSQL


Quote
Bruce Swart wrote:

> Can anyone give me a simple code example?
> I keep getting "Operation not applicable".

> Delphi 3, NT 4.0, BDE 4.51, Oracle 7.3 via ODBC

  Look at X:\DELPHI\DEMOS\DB\CACHEDUP. It's example.
Usually this error is occurring when TQuery.RecuestLive
property is True.

Ponch

Re:Cached updates with UpdateSQL


Hi Bruce,

Here's a snippet of code that I use in the OnUpdateRecord event of a dataset
that is using cached updates and has  a UpdateSql Object attached to the
dataset, hope it helps:

case UpdateKind of
       ukModify:
       begin
           upsReportItem.ModifySQL.Clear;
           upsReportItem.ModifySQL.Add('update GRM_REPORT_ITEM_LIST' +
           ' set REPORT_ID = :REPORT_ID,ITEM_ID = :ITEM_ID,GROUP_NAME =
:GROUP_NAME' +
           ' where REPORT_ID = :OLD_REPORT_ID and ITEM_ID = :OLD_ITEM_ID');
           upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);

           upsReportItem.ModifySQL.Clear;
           upsReportItem.ModifySQL.Add('update GRM_REPORT_ITEM set ITEM_ID =
:ITEM_ID,');
           upsReportItem.ModifySQL.Add('ITEM_LABEL = :ITEM_LABEL,ITEM_VALUE =
:ITEM_VALUE,');
           upsReportItem.ModifySQL.Add('ITEM_FONT_STYLE = :ITEM_FONT_STYLE,' +
               'ITEM_FONT_HEIGHT = :ITEM_FONT_HEIGHT,ITEM_COLOR = :ITEM_COLOR'
+
               ' where ITEM_ID = :OLD_ITEM_ID');
               upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);
       end;

       ukInsert:
       begin
           upsReportItem.InsertSQL.Clear;
           upsReportItem.InsertSQL.Add('insert into GRM_REPORT_ITEM' +
           '(ITEM_ID, ITEM_LABEL, ITEM_VALUE, ITEM_FONT_STYLE,
ITEM_FONT_HEIGHT,' +
           'ITEM_COLOR) values(:ITEM_ID, :ITEM_LABEL, :ITEM_VALUE,
:ITEM_FONT_STYLE,' +
           ' :ITEM_FONT_HEIGHT,:ITEM_COLOR)');
           upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);
           upsReportItem.InsertSQL.Clear;
           upsReportItem.InsertSQL.Add('insert into GRM_REPORT_ITEM_LIST ' +
           '(REPORT_ID, ITEM_ID, GROUP_NAME) values(:REPORT_ID, :ITEM_ID,
:GROUP_NAME)');
           upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);
       end;

       else
       begin
           upsReportItem.DeleteSQL.Clear;
           upsReportItem.DeleteSQL.Add('delete from GRM_REPORT_ITEM where
ITEM_ID = :OLD_ITEM_ID');
           upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);

           upsReportItem.DeleteSQL.Clear;
           upsReportItem.DeleteSQL.Add('delete from GRM_REPORT_ITEM_LIST' +
           'where REPORT_ID = :OLD_REPORT_ID and ITEM_ID = :OLD_ITEM_ID');
           upsReportItem.SetParams(UpdateKind);
           upsReportItem.ExecSQL(UpdateKind);
       end;
   end;
   UpdateAction := uaapplied;

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Other Threads