Solved

Deleting from a query

Posted on 1998-07-15
6
136 Views
Last Modified: 2010-04-04
In porting a d1 project to d3 I have found problems with code that deletes from a query. No I get a table is read only message. The query does not return a live result set even if requestlive is set to True as Order By is used. Anyway, I don't want a live result set I simply want to be ablt to delete some records from the query that I couldn't do with SQL. How can I set the query up so this is possible? Thanks, Tom.
0
Comment
Question by:tomcorcoran
[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
6 Comments
 
LVL 3

Expert Comment

by:KE
ID: 1357947
First of all, if you wan't to operate on the query data directly you will have to get a live set from the query.

You can also choose to update your table in a TTable, and get a unique identifier from your query for the TTable.

Lets say, you construct a huge query which would never be able to return a live set, no matter what you do. If your query at the same time request some unique row ID's, you can use these ID's in a TTable to delete/modify these rows.

Supply the query statement if you can't live without a live result set ;-) I'll see then if I can point out any non live-set aspects in it.
0
 
LVL 4

Expert Comment

by:jeurk
ID: 1357948
You could use a TUpdateSql to achieve what you want.
Look at it's help its explained right easily.
I've never used it but I know it should be done with that.
I hope it helps.
Jeurk
0
 

Author Comment

by:tomcorcoran
ID: 1357949
Hi,

I do not use a TUpDateSql as like I said I do not wish to update the TTable. KE, I did not understand what you were saying. I need to work with the modified query but not write the changes to the database.

Thanks, Tom.
0
Industry Leaders: 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!

 

Expert Comment

by:nileq
ID: 1357950
Hi,
Pleas supply the SQL Statment.
(By the way you don't use Query.Open, do you?)
0
 
LVL 3

Accepted Solution

by:
vladika earned 50 total points
ID: 1357951
Set Query1.CachedUpdates = True and
write such OnUpdateRecord handler

procedure TForm1.Query1UpdateRecord(DataSet: TDataSet;
  UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
  UpdateAction := uaApplied;
end;

Now you can modify your dataset as you want and
changes will not writes to the database.

0
 

Author Comment

by:tomcorcoran
ID: 1357952
Vladika, I knew there had to be a way, thanks a million, that works perfectly.
Tom.
0

Featured Post

Technology Partners: 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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

762 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