Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is this transaction sequence valid?
Message
From
19/12/2005 16:41:44
 
 
To
19/12/2005 16:29:15
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01079337
Message ID:
01079342
Views:
13
>Simplified, what I'm trying to do is similar to this:
>
>
>*  Code in controlling object:
>lFlag = .T.
>BEGIN TRANSACTION
>FOR EACH oObject IN colObjects
>
>   *  This next block of code is actually contained within each oObject,
>   *  it's not directly within the controlling object:
>   BEGIN TRANSACTION
>   SELECT oObject.cCursor
>   *  Make some sort of changes to the cursor
>   IF TABLEUPDATE(oObject.cCursor)
>      END TRANSACTION
>      RETURN .T.
>   ELSE
>      ROLLBACK
>      RETURN .F.
>   ENDIF
>   *  End of internal block of code
>
>   IF NOT lFlag      &&  Returned T/F from internal block of code
>      EXIT
>   ENDIF
>ENDFOR
>
>IF lFlag
>   END TRANSACTION
>ELSE
>   ROLLBACK
>ENDIF
>
>
>In essence, I am trying to update a series of cursors contained within a collection of objects, externally from a different controlling object. The objects in the collection aren't aware of the controlling object. I was hoping to be able to "undo" all of the changes, if any of the updates of the collection objects fails. Will this work?
>
>Thanks,
>Randy W.
>

No.
*  Code in controlling object:

BEGIN TRANSACTION
TRY
 FOR EACH oObject IN colObjects
   SELECT oObject.cCursor
   *  Make some sort of changes to the cursor
   IF TABLEUPDATE(oObject.cCursor)
      LOOP
   ENDIF
   * save the aError()
   ERROR "update fail on cursor "+oObject.cCursor
 ENDFOR
 END TRANSACTION
CATCH to ...
 * ...
FINALLY
  IF TXNLEVEL()>0
    ROLLBACK
  ENDIF
ENDTRY
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform