客戶端執行SHIP_ORDER的程序如下
procedure TFrmExecProc
begin
with DmEmployee do
begin
ShipOrderProc
ShipOrderProc
SalesTable
end;
end;
當用戶按ShipOrder按鈕時
法執行存儲過程
在CSDEMO應用程序中另一個使用存儲過程的TStoredProc部件是DeleteEmployeeProc
表
━━━━━━━━━━━━━━━━━━━━━━━━━━
屬性名 屬 性 值
──────────────────────────
DataBaseName EmployeeDemoDB
ParamBindMode PbByName
Params EMP_NUM(輸入參數
StoredProcName DELETE_EMPLOYEE
━━━━━━━━━━━━━━━━━━━━━━━━━━
存儲過程DELETE_EMPLOYEE的程序如下
PROCEDURE DELETE_EMPLOYEE
DECLARE VARIABLE any_sales INTEGER;
BEGIN
any_sales =
SELECT count(po_number)
FROM sales
WHERE sales_rep = :emp_num
INTO :any_sales;
IF (any_sales >
BEGIN
EXCEPTION reassign_sales;
SUSPEND;
END
UPDATE department
SET mngr_no = NULL
WHERE mngr_no = :emp_num;
UPDATE project
SET team_leader = NULL
WHERE team_leader = :emp_num;
DELETE FROM employee_project
WHERE emp_no = :emp_num;
DELETE FROM salary_history
WHERE emp_no = :emp_num;
DELETE FROM employee
WHERE emp_no = :emp_num;
SUSPEND;
END
Parameters:
EMP_NUM INPUT INTEGER
從上述存儲過程的例子中
在客戶/服務器應用程序中
Delphi中提供了事務的隱式和顯式兩種控制方法
Delphi擔當事務控制任務的部件是TDatabase
在CSDEMO中TDatabase 部件為EMployeeDatabase
CSDEMO中演示事務控制的窗體是TFrmTransDemo
DBGrid
procedure TFrmTransDemo
begin
DmEmployee
DmEmployee
end;
當窗口被關閉或隱藏時
procedure TFrmTransDemo
begin
DmEmployee
end;
窗口中有兩個按鈕BtnCommitEdits和BtnUndoEdits
procedure TFrmTransDemo
begin
if DmEmployee
(MessageDlg(
mtConfirmation
begin
DmEmployee
DmEmployee
DmEmployee
end else
MessageDlg(
end;
按下BtnUndoEdits按鈕將返轉當前事物
procedure TFrmTransDemo
begin
if DmEmployee
(MessageDlg(
begin
DmEmployee
DmEmployee
DmEmployee
end else
MessageDlg(
end;
返回目錄
編輯推薦
Java程序設計培訓視頻教程
J
Visual C++音頻/視頻技術開發與實戰
Oracle索引技術
ORACLE
Java程序性能優化
C嵌入式編程設計模式
Android游戲開發實踐指南
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/25128.html