Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Relational Databases
Expertise: Beginner
May 28, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

TQuery command to use to execute a SQL statement

I'm trying to delete multiple records using Tquery such as
delete from products p
   where p.shopno in
     (select shopno 
        from shops)
When I run the program, it executes the statements and deletes matching records but gives me an error message such as 'error creating cursor handle'. What is the reason and what can I do?

The only reason I can think of for this is that instead of issuing the ExecSQL command to execute the DELETE, you're issuing the Open command. Here are a couple of rules you should follow when using SQL in Delphi:

  1. Use the Open command for a TQuery or one of its descendants when you want to return a result set from the query that will be in the form of either a cursor handle or a batch moved to a persistent data store (TTable). This includes calling stored procedures called within the context of a SQL statement (i.e., SELECT * FROM MyStoredProc).
  2. Use the ExecSQL command for a TQuery or one of its descendants when the SQL operation does not return a result set. This applies to INSERT, UPDATE and DELETE queries that are table maintenance queries.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date