Solved

Deleting from a query

Posted on 1998-07-15
6
135 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
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 96
Working with hours 3 65
select query - oracle 16 100
Delphi Ado Query : Error Record is too large while trying to run ado query on Access database 2 63
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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