Changes between Version 9 and Version 10 of FDORfc61


Ignore:
Timestamp:
05/25/11 23:38:34 (14 years ago)
Author:
samwang
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc61

    v9 v10  
    3333
    3434class FdoSavePoint;
     35typedef  FdoNamedCollection<FdoSavePoint, FdoException> FdoSavePointCollection;
    3536
    3637class FdoITransaction : public FdoIDisposable
     
    5354    FDO_API virtual void Rollback(FdoString* savePointName) = 0;
    5455
    55     typedef  FdoNamedCollection<FdoSavePoint, FdoException> FdoSavePointCollection;
    56 
    5756    /// \brief
    5857    /// Get currently available save points.
     
    6160    /// Save point collection.
    6261    ///
    63     FDO_API virtual FdoSavePointCollection GetAvailableSavePoints() = 0;
     62    FDO_API virtual FdoSavePointCollection* GetAvailableSavePoints() = 0;
    6463    ......
    6564}
     
    6867{
    6968     public:
    70         FdoSavePoint( FdoStringP name, int rank );
    71         int GetRank()
    72         void SetRank(int rank);
     69        FdoSavePoint( FdoStringP name);
    7370        FdoStringP GetName();
    7471
     
    8784
    8885    private:
    89         int mRank;
    9086        FdoStringP mName;
    9187};
    9288}}}
    93 “!AddSavePoint” method is used to add a save point with a specific name which can later be rolled back to without affecting the work done prior to the save point. “Rollback” method rolls back to a named save point.
    94   A new class named "FdoSavePoint" is needed to represent a FDO save point, which has a name and a rank value to indicate the order defined in current transaction.
     89“!AddSavePoint” method is used to add a save point with a specific name which can later be rolled back to without affecting the work done prior to the save point. “Rollback” method rolls back to a named save point. A new class named "!FdoSavePoint" is needed to represent a FDO save point, which contains a name that has to be unique within the current transaction.
    9590
    9691The “FdoIConnectionCapabilities” interface also has to be extended to enable query for this capability:
     
    111106}}}
    112107
     108== How to use this API ==
     109
     110Add a save point/Rollback to a save point:
     111{{{
     112FdoPtr<FdoIInsert> insertCommand;
     113FdoPtr<FdoITransaction> transaction = connection->BeginTransaction();
     114transaction->AddSavePoint(L"Save_point_1");
     115try{
     116......
     117    insertCommand->SetTransaction(transaction)
     118    FdoIFeatureReader* reader = insertCommand->Execute();
     119......
     120}
     121catch(FdoException* e)
     122{
     123    e->Release();
     124    transaction->RollBack(L"Save_point_1");
     125}
     126transaction->AddSavePoint(L"Save_point_2");
     127FdoPtr<FdoIDelete> deleteCommand;
     128try{
     129......
     130    deleteCommand->SetTransaction(transaction)
     131    int num = deleteCommand->Execute();
     132......
     133}
     134catch(FdoException* e)
     135{
     136    e->Release();
     137    transaction->RollBack(L"Save_point_2");
     138}
     139transaction->Commit();
     140}}}
     141
     142Check if a save point is available:
     143{{{
     144FdoPtr<FdoITransaction> transaction;
     145......
     146FdoSavePointCollection* savePointCollection = transaction->GetAvailableSavePoints();
     147if(NULL != savePointCollection->FindItem(L"My_Save_Point"))
     148{
     149    ......
     150}
     151}}}
    113152
    114153== Managed FDO API ==