I’m trying to delete multiple records using Tquerysuch 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 theExecSQL command to execute the DELETE, you’re issuing the Open command. Hereare a couple of rules you should follow when using SQL in Delphi:
- 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 theform 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 SQLstatement (i.e., SELECT * FROM MyStoredProc).
- 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.