Search code examples
openedgeprogress-4gl

How can I delete a record in a table, based on dynamic queries?


This question is a follow-up of this one.

I currently have following piece of source code:

    CREATE BUFFER h-Table1 FOR TABLE "Table1" NO-ERROR.
    IF VALID-HANDLE(h-Table1)
    THEN DO:
             L-Found = h-Table1:FIND-FIRST("WHERE ...
             IF L-Found
             THEN h-Table1:BUFFER-DELETE().

When I launch the BUFFER-DELETE() command, I have error 335 (The Table1 record has NO-LOCK status. DELETE not allowed. (335)). How do I need to alter my source code in order to make this work? (How can I alter the status of my Table1 record?)


Solution

  • h-Table1:FIND-FIRST ("WHERE ....", EXCLUSIVE-LOCK) . 
    

    or after the first find (which should have been done with explicit NO-LOCK option)

    hTable1:FIND-CURRENT (EXCLUSIVE-LOCK) .