Results 1 to 2 of 2
  1. #1
    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)
    ansTbl Table
    updTbl Table
    qVar Query

    ; Move termed records
    qvar.readFromFile("select There.qbe")
    qVar.executeQBE ()
    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
    ansTbl.empty ()
    msgInfo ("Done!", "Done moving records to termed account database.")

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts