Solved

How to change the index of query at runtime?

Posted on 1998-11-27
11
207 Views
Last Modified: 2010-04-04
1. How to change the primary key of query at runtime?
2. Can i do it when the query is open?
3. How to use the second index with query?

Thanks for any help.

Ye Chen
0
Comment
Question by:yc
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1348252
hi yc,

what does you mean? a query has no primary key and no second index. Some databases use indexes automatically for the query some must explezit said to use an index for the query.

for changes a must query closed and reopened except changes on the filteroptions.

meikl
0
 
LVL 1

Expert Comment

by:EmmDieh
ID: 1348253
The query optimizer of the underlying database system chooses the indexes automatically. Sometimes you can manually add your own plan of the indexes used.
In order to sort the result set of a query you'll have to use the "order by" clause of the "select" statement. To apply different sort orders you'll have to close the query change the "order by" clause und re-open the query.
Ex.:  select a, b, c from d order by c, b, a
So, you cannot change the order of the rows of the query-result-set while the query is open.

0
 

Author Comment

by:yc
ID: 1348254
Hi, EmmDieh

When i use "order by " in SQL clause, i can modify but not update the query through DBGrid. Why?

It is very important for me to modify and post when use non-primary index!

Thanks for your help.

Ye Chen
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1348255
When using "order by", the result can no longer be a live result. However, you can user UpdateSQL to implement that. So you can use most of the conditional sub-clauses as well as modify the result.
0
 

Author Comment

by:yc
ID: 1348256
Hi, dwwang
 
Would you give me an example of UpdateSQL which using "order by".
 
Merry Christmas and Happy New Year!

Ye Chen

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:dwwang
ID: 1348257
Hi, an example is too complex to provide here, you can see the help on TUpdateSQL component in Delphi, there are detailed explanations as well as examples.

The main idea is that your input to the query is cached, and when you call ApplyUpdates, system will run the SQL statement stored in the TUpdateSQL component to perform the updates. If this helps, leave a message :-)

Merry Christmas and Happy New Year!

Regards,
Wang
0
 

Author Comment

by:yc
ID: 1348258
Hi, dwwang
 
I had added the sqlupdate compontent to my application.
But it seems do not work.
 
I wander you send a simple example to my mailbox? (yc@1lansuite.com)

BTW: The points is increased to be 100. :)
 
Thanks very much.
 
Ye Chen
0
 

Author Comment

by:yc
ID: 1348259
Hi, dwwang

my E-mail address is yc@lansuite.com

wait you.

Y.C.
0
 
LVL 4

Accepted Solution

by:
dwwang earned 150 total points
ID: 1348260
Hi, it's very kind of you increasing the points to 100 :-), so I post it as an answer.

Actually if you are using D3 or above versions, there is an example showing exactly what you want in the "demos\db\cachedup" directory. However, you must have Local Interbase installed on you machine to get it work.

So if you still would like me to mail you the example, I can try to modify it into an example that use DBDEMOS(paradox), so that you can run it without problem.

Regards,
Wang
0
 

Author Comment

by:yc
ID: 1348261
Hi, dwwang

I hadn't installed the Local Interbase on my machine.
I am using Delphi 4.01

Please mail me the example which use TDBGrid, TQuery, TDatabase, TUpdateSQL, TDataSource and a Button to UpdateCache.

Thanks very much.

Ye Chen

0
 

Author Comment

by:yc
ID: 1348262
Adjusted points to 150
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
loading dll from external path 1 210
Machine not responding during CopyFile() 3 88
delphi prevent click fast 2 189
Best Firemonkey component pack 1 86
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now