Changes between Version 9 and Version 10 of FDORfc61
- Timestamp:
- 05/25/11 23:38:34 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FDORfc61
v9 v10 33 33 34 34 class FdoSavePoint; 35 typedef FdoNamedCollection<FdoSavePoint, FdoException> FdoSavePointCollection; 35 36 36 37 class FdoITransaction : public FdoIDisposable … … 53 54 FDO_API virtual void Rollback(FdoString* savePointName) = 0; 54 55 55 typedef FdoNamedCollection<FdoSavePoint, FdoException> FdoSavePointCollection;56 57 56 /// \brief 58 57 /// Get currently available save points. … … 61 60 /// Save point collection. 62 61 /// 63 FDO_API virtual FdoSavePointCollection GetAvailableSavePoints() = 0;62 FDO_API virtual FdoSavePointCollection* GetAvailableSavePoints() = 0; 64 63 ...... 65 64 } … … 68 67 { 69 68 public: 70 FdoSavePoint( FdoStringP name, int rank ); 71 int GetRank() 72 void SetRank(int rank); 69 FdoSavePoint( FdoStringP name); 73 70 FdoStringP GetName(); 74 71 … … 87 84 88 85 private: 89 int mRank;90 86 FdoStringP mName; 91 87 }; 92 88 }}} 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. 95 90 96 91 The “FdoIConnectionCapabilities” interface also has to be extended to enable query for this capability: … … 111 106 }}} 112 107 108 == How to use this API == 109 110 Add a save point/Rollback to a save point: 111 {{{ 112 FdoPtr<FdoIInsert> insertCommand; 113 FdoPtr<FdoITransaction> transaction = connection->BeginTransaction(); 114 transaction->AddSavePoint(L"Save_point_1"); 115 try{ 116 ...... 117 insertCommand->SetTransaction(transaction) 118 FdoIFeatureReader* reader = insertCommand->Execute(); 119 ...... 120 } 121 catch(FdoException* e) 122 { 123 e->Release(); 124 transaction->RollBack(L"Save_point_1"); 125 } 126 transaction->AddSavePoint(L"Save_point_2"); 127 FdoPtr<FdoIDelete> deleteCommand; 128 try{ 129 ...... 130 deleteCommand->SetTransaction(transaction) 131 int num = deleteCommand->Execute(); 132 ...... 133 } 134 catch(FdoException* e) 135 { 136 e->Release(); 137 transaction->RollBack(L"Save_point_2"); 138 } 139 transaction->Commit(); 140 }}} 141 142 Check if a save point is available: 143 {{{ 144 FdoPtr<FdoITransaction> transaction; 145 ...... 146 FdoSavePointCollection* savePointCollection = transaction->GetAvailableSavePoints(); 147 if(NULL != savePointCollection->FindItem(L"My_Save_Point")) 148 { 149 ...... 150 } 151 }}} 113 152 114 153 == Managed FDO API ==