DataSnap 設計上簡直可以取代 Database Trigger 了

這一陣子一直在改良 DataSnap 雲端服務器的效能。

想說 ProviderFlags 可以自動產出 SQL 碼,但礙於必須做更新前、後的處理,所以當時還是人工刻指令。

DSP.BeforeUpdateRecord 很認真的又重看了一次,再看到自己很久以前的貼文:
請問有關 DataSetProvider->BeforeUpdateRecord 用法

The Sender parameter identifies the provider that is applying updates.

The SourceDS parameter is the dataset from which the data originated. If there is no source dataset, this value is NULL. The source dataset may not be active when the event occurs, so set its Active property to true before trying to access its data.

The DeltaDS parameter is a client dataset containing all the updates that are being applied. The current record represents the update that is about to be applied.

The UpdateKind parameter indicates whether this update is the modification of an existing record (ukModify), a new record to insert (ukInsert), or an existing record to delete (ukDelete).
UpdateKind參數標示觸發事件的變更項:更新現有資料(ukModify), 新增記錄(ukInsert)或是刪除現有資料(ukDelete)

The Applied parameter controls what happens after exiting the event handler. If the event handler sets Applied to true, the provider ignores the update: it neither tries to apply it, nor does it log an error indicating that the update was not applied. If the event handler leaves Applied as false, the provider tries to apply the update after the event handler exits.
Applied參數是指發生在離開事件之後的控制。假如設定為true, Provider會將忽略更新:不套用,也不做例外處理和error log記錄(如果有的話);如果為false,則Provider會在離開該事件後再嘗試進行套用更新的工作。

現在的我,看完後又有了一層新的體悟,隨即嚐試著實作看看,想不到真的會自動產出並執行 SQL 指令,而且效能比自己 DIY 要來的更好,Devart DBX Driver 買得真是值得。

最後還完成更新前處理和更新後處理,也就是說,我居然也在 DataSnap 做出類似像 Database Trigger 的功能。

DataSnap 的設計理念到現在我還是覺得好先進,真是超完美的雲端框架!(無誤



DataSnap REST API Authorization with PHP

About Authentication with DataSet REST JavaScript client. In connection.js: function setCredentials(user, password) { connectionInf...