Solved

Deleting from a query

Posted on 1998-07-15
6
130 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:nileq
Comment Utility
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
Comment Utility
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
Comment Utility
Vladika, I knew there had to be a way, thanks a million, that works perfectly.
Tom.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

7 Experts available now in Live!

Get 1:1 Help Now