Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDQuery as a ClientDataset



Permlink Replies: 1 - Last Post: Jul 28, 2017 1:56 AM Last Post By: Bernd Maierhofer
Pablo Romero

Posts: 21
Registered: 9/28/00
TFDQuery as a ClientDataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 27, 2017 8:30 AM
Hi Evertybody...

I use Delphi XE3 and Delphi XE7. And I have this question:

I have a huge query. I use TFDQuery to get it. It's a big "SELECT..." from a Firebird database

I need transvers that query to update some data and show the records in a TDbGrid.

Every time I use something like this, for example:


MyQuery.sql.text := 'SELECT COLUMN1, COLUMN2...from ....INNER JOIN...blablabla"
 
MyQuery.open;
 
While not MyQuery.eof do
begin
     MyQuery.edit;
     MyQuery.FieldByName('COLUMN2').AsFloat  := MyQuery.FieldByName('COLUMN1').AsFloat / nSomeValueFromSomeProcess
 
....lot of changes....
 
    MyQuery.Post;  //<-----ERROR HERE
 
    MyQuery.Next;
end;
 


The Error is "COLUMN2 unkwon".

The real question is "Is it possible to use a TFXQuery like a TClientDataset?"

Regards,
Pablo Romero

Edited by: Pablo Romero on Jul 27, 2017 12:31 PM
Bernd Maierhofer

Posts: 161
Registered: 9/27/99
Re: TFDQuery as a ClientDataset [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 28, 2017 1:56 AM   in response to: Pablo Romero in response to: Pablo Romero
Pablo Romero wrote:

Hi Evertybody...

I use Delphi XE3 and Delphi XE7. And I have this question:

I have a huge query. I use TFDQuery to get it. It's a big "SELECT..."
from a Firebird database

I need transvers that query to update some data and show the records
in a TDbGrid.

Every time I use something like this, for example:

 
MyQuery.sql.text := 'SELECT COLUMN1, COLUMN2...from ....INNER
JOIN...blablabla"
 
MyQuery.open;
 
While not MyQuery.eof do
begin
     MyQuery.edit;
     MyQuery.FieldByName('COLUMN2').AsFloat  :=
MyQuery.FieldByName('COLUMN1').AsFloat / nSomeValueFromSomeProcess
 
....lot of changes....
 
    MyQuery.Post;  //<-----ERROR HERE
 
    MyQuery.Next;
end;
 


The Error is "COLUMN2 unkwon".

The real question is "Is it possible to use a TFXQuery like a
TClientDataset?"

Regards,
Pablo Romero

Edited by: Pablo Romero on Jul 27, 2017 12:31 PM

From the Docs:
FireDAC will use the main (first) table in the SELECT ... FROM ...
statement, as an updating table name.

Maybe Column2 does not belong to the first table?

See here:
http://docwiki.embarcadero.com/RADStudio/XE5/en/Update_Command_Generatio
n_(FireDAC)

brgds Bernd
--
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02