Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this transaction sequence valid?
Message
De
19/12/2005 16:41:44
 
 
À
19/12/2005 16:29:15
Randy Witt
Diamond Vogel Paints
Orange City, Iowa, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01079337
Message ID:
01079342
Vues:
12
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform