Thread: using subtract in a script
07-13-04, 12:31 #1Registered User
- Join Date
- Jul 2004
Unanswered: using subtract in a script
I borrowed script from a users guide and made changes that allowed me to ADD records from a query table "Answer.db" to a history table "test GBB 3". I've tried to use SUBTRACT in the next line to remove the same records from the source table "test GBB 1" where the query pulled from. I can accomplish what I want to do using Subtract as a menu choice under the utilities menu and it works fine. I can't seem to get the script to recognize the Subtract command. FYI I can't use the delete feature in a query because of locks in some tables. Any help would be appreciated. Here's my script:
method run(var eventInfo Event)
; Move termed records
ansTbl.attach("riv:Answer.db", "Paradox") ;attach the answer table
ansTbl.add("test GBB 3",True,False) ;append records from answer to test gbb 3
ansTbl.subtract("test GBB 1",True,False) ;deletes record from source table
msgInfo ("Done!", "Done moving records to termed account database.")
07-21-04, 17:20 #2Registered User
- Join Date
- Aug 2003
- Bologna - Italy
First thing: if you can't delete records by means of a delete query because of a table lock, THERE'S NO WAY YOU CAN DELETE RECORDS BY ANY MEANS.
Table locks come before any Pdox operation, they are managed at the BDE level, so you WON'T be able to circumvent them.
So you must find what piece of your code leaves you with a lock on the table, and correct it; sometimes it can be even only a tcursor that hasn't been closed, or a form using this table is open; since add and subtract need an exclusive lock to the table, NOTHING coud be using the table when you do these commands.
That said, i advise you to refrain from using tables which have spaces in theyr names: that surely can become a problem in many situations like this.
In any way, that operation you're trying to do should be done by queries, which do not need an exclusive lock on the table, and should be done ONLY after verifying that there's NO referential integrity link at all ending on the record you're deleting.The only failure is not trying to do it.