Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Using DBISAMUpdateSQL
Fri, Jun 9 2006 1:12 AMPermanent Link

"Gregor Dollhof"
Hi
I am trying to get TDBISAMQuery - TDBISAMUpdateSQL to work like TQuery -
TUpdateSQL. In the 'afterdelete'-event of TQuery I normally 'apply' the
changes; since there is no 'apply' with DBISAMQuery I experimented with
'begincachedupdates' and 'applycachedupdates' but nothing happens (record is
not deleted - no complaints from the engine though). What is the correct
procedure for using DBISAMUpdateSQL? It's a canned result.

BTW the syntax for SQL-Delete:

delete from articles
where
 articlenr = :OLD_articlenr and
 symptomnr = :OLD_symptomnr

Fri, Jun 9 2006 10:56 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Gregor,

<< I am trying to get TDBISAMQuery - TDBISAMUpdateSQL to work like
TQuery -TUpdateSQL. In the 'afterdelete'-event of TQuery I normally 'apply'
the changes; since there is no 'apply' with DBISAMQuery I experimented with
'begincachedupdates' and 'applycachedupdates' but nothing happens (record is
not deleted - no complaints from the engine though). What is the correct
procedure for using DBISAMUpdateSQL? It's a canned result. >>

You can only use TDBISAMUpdateSQL with TClientDataSet.  It doesn't work with
TDBISAMQuery components.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jun 12 2006 12:14 PMPermanent Link

Chris Erdal
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in
news:65C3B020-6235-4295-9217-D594140615DE@news.elevatesoft.com:

> You can only use TDBISAMUpdateSQL with TClientDataSet.  It doesn't
> work with TDBISAMQuery components.
>

Well I also wanted to use the TDBISAMUpdateSQL component with a
TDBISAMQuery, before I learnt its limitations, so I did this:

(N.B. tblMaster is a TDBISAMQuery, and updMaster is its TDBISAMUpdateSQL)

procedure TDBISAMAdvStrGrdForm.tblMasterBeforePost(DataSet: TDataSet);
var i:Integer;
   aFld:TField;
   aFldNames,aFldValues:String;
begin
 inherited;
 if tblMaster.ResultIsLive then
   exit;

 // preparer chaque champ qui a été modifiée dans le SQL insert / Update
 if dsInsert = DataSet.State then
 begin
   for i:=0 to pred(Dataset.FieldCount) do
   begin
     aFld := DataSet.Fields[i];
     if (pos(UpdTableName+'.',aFld.Origin) = 1) and
        (aFld.FieldKind = fkData) and
        (aFld.NewValue <> aFld.OldValue) then
     begin
       if aFldNames > '' then
       begin
         aFldNames := aFldNames + ',';
         aFldValues := aFldValues + ',';
       end;
       aFldNames := aFldNames+aFld.FieldName;
       aFldValues := aFldValues+':'+aFld.FieldName;
     end;
   end;
   if aFldNames = '' then
     abort; // pas de valeurs à insérer
   updMaster.InsertSQL.Text := 'INSERT INTO
'+UpdTableName+'('+aFldNames+') VALUES('+aFldValues+')';
   updMaster.Apply(ukInsert);
   Showmessage(IntToStr(updMaster.Query[ukInsert].RowsAffected)+' lignes
insérées');
 end
 else if dsEdit = DataSet.State then
 begin
   for i:=0 to pred(Dataset.FieldCount) do
   begin
     aFld := DataSet.Fields[i];
     if (pos(UpdTableName+'.',aFld.Origin) = 1) and
        (aFld.FieldKind = fkData) and
        (aFld.NewValue <> aFld.OldValue) then
     begin
       if aFldNames > '' then
       begin
         aFldNames := aFldNames + ',';
         aFldValues := aFldValues + ',';
       end;
       aFldNames := aFldNames+aFld.FieldName+'=:'+aFld.FieldName;
     end;
   end;
   if aFldNames = '' then
     abort; // pas de valeurs à modifier
   updMaster.ModifySQL.Text := 'UPDATE '+UpdTableName+' SET
'+aFldNames+WhereClause;
   updMaster.Apply(ukModify);
   Showmessage(IntToStr(updMaster.Query[ukModify].RowsAffected)+' lignes
modifiées');  
 end;
end;

--
Chris
Tue, Jun 13 2006 5:11 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< Well I also wanted to use the TDBISAMUpdateSQL component with a
TDBISAMQuery, before I learnt its limitations, so I did this: >>

Nice job. Smiley Thanks for posting that code, I'm sure it will be extremely
helpful to others.

--
Tim Young
Elevate Software
www.elevatesoft.com



Image