TSmartyQuery

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chads
Posts: 2
Joined: Wed 09 Apr 2008 01:58

TSmartyQuery

Post by chads » Wed 09 Apr 2008 02:07

I'm using a TSmartQuery component to edit the data in a table. While running/stepping through the code I can see that the field of the component is being updated. However, when I commit my changes (TOraSession.Commit) they aren't committed to the database. After the commit I can see the data has been and is still edited (via a Watch).

I'm assuming it's one of the properties of the component that I haven't set correctly but maybe not? Any suggestions?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 09 Apr 2008 07:49

You should call Edit method before editing a record and Post method after editing. For example:

Code: Select all

  SmartQuery.Edit;
  SmartQuery.FieldByName('A').AsString := 'aa';
  SmartQuery.Post;
If you do not start transaction manually, TSmartQuery component autocommits changes. So you don't need to call TOraSession.Commit method.

chads
Posts: 2
Joined: Wed 09 Apr 2008 01:58

Post by chads » Wed 09 Apr 2008 13:41

Plash,
I'm in a transaction before I get to the code set that is editing the data. Also, I have already tried invoking the post method after the edit.

Here's an example of my code set:
SmartQuery.FieldByName('FIELD1').OnChange := nil;
SmartQuery.First;
while not SmartQuery.Eof do
begin
if (SmartQuery.FieldByName('FIELD1').AsString = '') and
(SmartQuery.FieldByName('FIELD2').AsInteger 10) then
begin
SmartQuery.Edit;
SmartQuery.FieldByName('FIELD1').AsFloat := .10;
SmartQuery.Post;
end; //end
SmartQuery.Next;
end; //while

Any other ideas?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 10 Apr 2008 07:06

Please check that an update query is executed when you call Post method. You need to set Debug property of TSmartQuery component to True, and add OdacVcl unit to 'uses'. When Post method is called, the dialog with the text of UPDATE statement should appear.

Post Reply