Board index » delphi » Referencing another TDataset from within a TQuery's SQL

Referencing another TDataset from within a TQuery's SQL

If I have a TQuery component on a form, containing a result set, can I query
that result set from another TQuery?  Possibly another way to ask this would
be: Can I reference another TDataset from within a TQuery's SQL?

Thanks,
Alan

 

Re:Referencing another TDataset from within a TQuery's SQL


Hi Alan,

As far as I know the answer is no.
Because when u create a TQuery, result is a temporary table on the comp. that
you exec the query. On the other hand TTable browses the tables as online from
the database. But you have a chance to create a live TQuery, but this is a
different scenario, because when you update the TQuery, Delphi updates the table
at the backgroud using SQL statements.

I hope this helps you and I hope I am not wrong.
Yusuf

Re:Referencing another TDataset from within a TQuery's SQL


On Fri, 2 Jul 1999 11:50:18 -0500, "Alan McKeen" <A...@MI-Assistant.com>
wrote:

Quote
>If I have a TQuery component on a form, containing a result set, can I query
>that result set from another TQuery?  Possibly another way to ask this would
>be: Can I reference another TDataset from within a TQuery's SQL?

No. The result set produced by TQuery cannot be used in this manner. Tables
referenced in SQL statements executed from TQuery components must be base
tables or VIEWs in the database.

You can save the result set to a temporary table and then use that in the
second statement. Save query result sets to tables using such means as the
TBatchmove component and the BDE API function DbiMakePermanent.

Alternately, you could incorporate the first SQL statement into the second.
This is not using the first query's result set in the second query. It is
using the first query's building of a result set.

==========================================================================
Steve Koterski                  "Computers are useless. They can only give
Technical Publications          you answers."
Borland                                       -- Pablo Picasso (1881-1973)
http://www.borland.com/techpubs/delphi

Re:Referencing another TDataset from within a TQuery's SQL


Hi Alan!

On Fri, 2 Jul 1999 11:50:18 -0500, "Alan McKeen"

Quote
<A...@MI-Assistant.com> wrote:
>If I have a TQuery component on a form, containing a result set, can I query
>that result set from another TQuery?  Possibly another way to ask this would
>be: Can I reference another TDataset from within a TQuery's SQL?

The only way to do that is using Lookup DataFields, this enables you
to add a field to dataset that is actually looked up from some other
dataset on the basis of some fields from original dataset.

In the form on wich you have two datasets go to fields editor and
there press Ins key and when "New Field" dialog shows up select Lookup
radio button for Field Type ...

explore delphi help for more info on Lookup datafields.

tomi.

Other Threads