Board index » delphi » TQuery on TQuery result set??

TQuery on TQuery result set??

I have a TQuery performed on a Table with a result set.
Now I want to do a query on this result set, what do i do??

Thanks

 

Re:TQuery on TQuery result set??


One way is to save the query dataset to a temporary table using
TBatchMove. Then query the temp table. Database servers (Oracle,
Sybase, Interbase...) allow nested queries which will do what you need
in one step. The BDE can't do this with Pdox or dBase tables, AFAIK.

HTH,
Dan
.

Quote
On Thu, 21 May 1998 14:24:35 GMT, and...@aelhk.com (Anders LEE) wrote:

>I have a TQuery performed on a Table with a result set.
>Now I want to do a query on this result set, what do i do??

>Thanks

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control: Consulting, Software,
and the only comprehesive textbook on this subject.
visit us at www.cmdcsystems.com
[Remove the SPAM from my e-mail address]

Re:TQuery on TQuery result set??


Make it permanent (use dbyMakePermanent(qry.handle,
'ThisQuery.DB',true) and include BDE in your uses clause) and
run a query against what you made permanent.

Nick Spurrier (MoDESoft, UK)

Re:TQuery on TQuery result set??


On 22 May 1998 16:10:12 GMT, n...@mode.co.uk (Nick Spurrier) wrote:

Quote
>Make it permanent (use dbyMakePermanent(qry.handle,
>'ThisQuery.DB',true) and include BDE in your uses clause) and
>run a query against what you made permanent.

>Nick Spurrier (MoDESoft, UK)

  Where is dbyMakePermanent ??

  Can you give a little more clear sample code ??

Re:TQuery on TQuery result set??


On 22 May 1998 16:10:12 GMT, n...@mode.co.uk (Nick Spurrier) wrote:

Quote
>Make it permanent (use dbyMakePermanent(qry.handle,
>'ThisQuery.DB',true) and include BDE in your uses clause) and
>run a query against what you made permanent.

>Nick Spurrier (MoDESoft, UK)

   I now figure it out how to use this
            DBiMakePermanant(...)

   But two of my numerica fields appear as unknown field type in
Database desktop, and when I do a query on it, it doesn't return the
required value.

  How do I 'force' it into numberic fields ??

2nd, the output file doesn't look like a dbase IV file (which my
sources are)  How can I control it ??

Re:TQuery on TQuery result set??


Quote
Anders LEE wrote:

> On 22 May 1998 16:10:12 GMT, n...@mode.co.uk (Nick Spurrier) wrote:

> >Make it permanent (use dbyMakePermanent(qry.handle,
> >'ThisQuery.DB',true) and include BDE in your uses clause) and
> >run a query against what you made permanent.

> >Nick Spurrier (MoDESoft, UK)

>   Where is dbyMakePermanent ??

>   Can you give a little more clear sample code ??

I also needed this feature, and got it also to work. Now I don't need BatchMove
any more to build a temporary tables for the second SQL search.

  dQuery.Close;
  dQuery.Open;
  dbiMakePermanent(dQuery.Handle,'DelaQry.DB',True);

The slight problem is that the new Table 'DelaQry.DB' will by default be
positioned to the directory where BDE's PrivateDir is pointing.

In my case database files are in directory \DATA and PrivateDir points
to \PRIV. You can hard code the second SQL clause to use tables from both of
these directories, but it seems I can't give the Table name or path as a SQL
parameter.

You could direct the SQL temporary files to go to the same \DATA directory
as the database files:
 dbiMakePermanent(dQuery.Handle,'C:\DATA\DelaQry.DB',True);
but in multi user environment I suppose it's not very wise thing to do.

Markku Nevalainen

Re:TQuery on TQuery result set??


You need to use dbiMakePermanent(table.handle, 'Mytable.DBF',
true) to force the table type to dBase. It defaults to
Paradox otherwise. You should then end up with standard
NUMERIC(10,2) fields for the numeric ones.

Re:TQuery on TQuery result set??


On 27 May 1998 13:55:46 GMT, n...@mode.co.uk (Nick Spurrier) wrote:

Quote
>You need to use dbiMakePermanent(table.handle, 'Mytable.DBF',
>true) to force the table type to dBase. It defaults to
>Paradox otherwise. You should then end up with standard
>NUMERIC(10,2) fields for the numeric ones.

 I already name it as MyTable.DBF
 But I think it is still a Paradox table.
 However, since the sole purpose is do a seond query, it is ok.
 But when I browse it with DataBase Desktop, the two numeric fields
are left justified.  I wonder if it will cause any trouble.

Other Threads