Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Branching a TQuery after executing SQL

Posted on 1998-07-28
7
Medium Priority
?
230 Views
Last Modified: 2010-04-04
A little background info here.  I'm accessing a FoxPro table / database from a CD-ROM (ick!).  There are lots of tables, but one huge *mutha* of a table that takes up most of the CD.  Now, imagine doing a SQL query on that...  sorted, even...  now you have entered my little room in hell.

Okay, I'm going thru various testing ideas here to help speed this thing up.  There comes a point after the first SQL execution where I need to "fine tune" the data, in a branching kind of way.  I need a subset of the original query, while keeping the original query.  

Can this be done without executing a new query?

I know about the Filter property on a query, but that doesn't allow me to branch off...

I wish there was something like a query.assign where it could just transfer over the guts and then I could apply the filters.

Any hints?

thanks,
-gd
0
Comment
Question by:greendot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358847
... what about using temp queries in SQL code?
0
 
LVL 2

Author Comment

by:greendot
ID: 1358848
Oh mm...
(I'm somewhat of an upper-novice with SQL)
Could you explain a little more about temp queries?

thx,
j

0
 
LVL 1

Expert Comment

by:andrey070798
ID: 1358849
Hi, gd!

I have question.
  You HAVE this Database on the CD and your problem to speed it up for you
     OR
  you CREATING Database (you'll store it in a CD) and all you want to speed up work in the future?
If you're CREATING it I can help a little bit.
But if you already have data structure and it's on the CD I think there is difficult to change it.
May be I'm wrong.
Andrey.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:greendot
ID: 1358850
The tables are already out on the CD.  We can't change them.
(That's the next version.. yay)

I'm just trying to find ways to speed things up.  There is one point where I have to print a report and do a query on the huge (100-600 meg) file.  I can measure this in hour/query. ick.

So I was wanting to branch so I could apply the filters on those seperately, without the entire query being run again.

My thinking is I do the query to gather in the fields and define the sort order, then split it off and filter off the little "subqueries".

-gd
0
 
LVL 3

Accepted Solution

by:
vladika earned 400 total points
ID: 1358851
I wrote small component CloneQuery which can clone existing dataset.
Set MasterQuery property, then open MasterQuery
After MasterQuery opened you can open CloneQuery.
Then you can apply your filter to CloneQuery.
You can improve my component.

unit CloneQuery;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  BDE, Db, DBTables;

type
  TCloneQuery = class(TQuery)
  private
    FMasterQuery: TQuery;
    procedure SetMasterQuery(Value: TQuery);
  protected
    function CreateHandle: HDBICur; override;
    procedure Notification(AComponent: TComponent;
      Operation: TOperation); override;
  published
    property MasterQuery: TQuery read FMasterQuery write SetMasterQuery;
  end;

procedure Register;

implementation

procedure TCloneQuery.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (FMasterQuery <> nil) and
    (AComponent = FMasterQuery) then FMasterQuery := nil;
end;

procedure TCloneQuery.SetMasterQuery(Value: TQuery);
begin
  if Value = Self then Exit;
  FMasterQuery := Value;
  if Value <> nil then Value.FreeNotification(Self);
end;

function TCloneQuery.CreateHandle: HDBICur;
begin
  if (FMasterQuery <> nil) and (FMasterQuery.Active) then
    Check(DbiCloneCursor(FMasterQuery.Handle, False, False, Result))
  else Result := nil;
end;

procedure Register;
begin
  RegisterComponents('ExpertExchange', [TCloneQuery]);
end;

end.

0
 
LVL 3

Expert Comment

by:vladika
ID: 1358852
greendot, where are you?
What do you think about my solution?

0
 
LVL 2

Author Comment

by:greendot
ID: 1358853
Oops,
sorry vladika, but I haven't had a chance to get at it yet.
I made the component, and put it in the component tray..
but haven't tested.  :\

I should be able to get at it either this weekend or on Monday.
But off hand, it looks like this is what I want.  :)

-gd
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question