Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Transaction Processing
http://ebiztechnics.blogspot.com
Objectives
• Describe Transaction Processing in Forms
• Commit Triggers and Usage
• Commit Status
• Implementing Array DML...
Transaction Processing
Save
Transaction (Begin)
FORM A
Block#1
Block#2
New Record
Updated Record
Deleted Record
Updated Re...
Transaction Processing
Transaction processing consists of two phases:
• Post:
– Writes record changes to base tables
– Fir...
Commit Sequence of Triggers
Pre-Commit
Pre-Delete
Post-Delete
Delete row
1
More
Records
http://ebiztechnics.blogspot.com
Commit Sequence of Triggers
Pre-Insert
Post-Insert
1
Insert
Insert row
Pre-Update
Post-Update
Update
Update row
Post-Datab...
Commit Triggers
• Pre-Commit: Fires once if form changes are made or uncommitted
changes are posted
• Pre- and Post-DML
• ...
Commit Triggers
• Post-Forms-Commit: Fires once even if no changes are made
• Post-Database-Commit: Fires once even if no ...
Usage of Commit Triggers
Pre-Commit
Pre-Delete
Pre-Insert
Pre-Update
Check user authorization; set up special locking
Jour...
Usage of Commit Triggers
On-Insert/Update/Delete
Post-Forms-Commit
Post-Database-Commit
Replace default block
DML statemen...
Update Processing
ColumnItem
Query
Rollback
Data
20 20
Locked
Query
Commit 30 30
30 20Update record in form
[Save] 30 20[S...
Pre-Delete Trigger
• Check Before Deletion
DECLARE
CURSOR empcur IS
SELECT ’x’ FROM dept
WHERE deptno = :emp.deptno;
BEGIN...
Assigning Sequence Nos.
• Pre-Insert Trigger
SELECT empseq.nextval
INTO :emp.empno
FROM dual;
Note: Sequence value will be...
Keeping an Audit Trail
• Write changes to nonbase tables.
• Gather statistics on applied changes.
Post-Insert example:
:GL...
Test the success of DMLs
• SQL%FOUND
• SQL%NOTFOUND
• SQL%ROWCOUNT
UPDATE …….
SET…..
WHERE …..;
IF SQL%NOTFOUND THEN
MESSA...
DML Statements Issued During Commit
Processing
INSERT INTO base_table (base_column, base_column,...)
VALUES (:base_item, :...
DML Statements Issued During Commit
Processing
Rules:
• DML statements may fire database triggers.
• Form Builder uses and...
Overriding default transaction
On-Check-Unique
On-Column-Security
On-Commit
On-Rollback
On-Savepoint
On-Sequence-Number
CH...
Commit Status
• What is Commit Status?
• SYSTEM.RECORD_STATUS:
– NEW
– INSERT (also caused by control items)
– QUERY
– CHA...
Commit Status
• SYSTEM.FORM_STATUS:
– NEW
– QUERY
– CHANGED
• System variables versus built-ins for commit status
• Built-...
Commit Status
• Do not confuse commit status with validation status.
• The commit status is updated during validation.
IF ...
Array DML
• Performs array inserts, updates, and deletes
• Vastly reduces network traffic
Fewer round trips (exact
number ...
Effect of Array DML on Transactional
Triggers
Array DML Size = 1 Array DML Size > 1
Fires
Fires for each
insert, update,
d...
Implementing Array DML
1. Enable the Array Processing option.
2. Specify a DML Array Size of greater than 1.
3. Specify bl...
Summary
• Post and commit phases
• Flow of commit processing
• DML statements issued during commit processing
• Characteri...
Prochain SlideShare
Chargement dans…5
×

Oracle Forms : Transnational Triggers

2 717 vues

Publié le

Oracle Forms: Transnational Triggers

Publié dans : Logiciels
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Oracle Forms : Transnational Triggers

  1. 1. Transaction Processing http://ebiztechnics.blogspot.com
  2. 2. Objectives • Describe Transaction Processing in Forms • Commit Triggers and Usage • Commit Status • Implementing Array DML http://ebiztechnics.blogspot.com
  3. 3. Transaction Processing Save Transaction (Begin) FORM A Block#1 Block#2 New Record Updated Record Deleted Record Updated Record Commit work;Commit work; INSERT INTO Table1INSERT INTO Table1 UPDATE Table1UPDATE Table1 DELETE FROM Table2DELETE FROM Table2 UPDATE Table2UPDATE Table2 Transaction (End) Action Edit http://ebiztechnics.blogspot.com
  4. 4. Transaction Processing Transaction processing consists of two phases: • Post: – Writes record changes to base tables – Fires transactional triggers • Commit: Performs database commit Errors result in: • Rollback of the database changes • Error message http://ebiztechnics.blogspot.com
  5. 5. Commit Sequence of Triggers Pre-Commit Pre-Delete Post-Delete Delete row 1 More Records http://ebiztechnics.blogspot.com
  6. 6. Commit Sequence of Triggers Pre-Insert Post-Insert 1 Insert Insert row Pre-Update Post-Update Update Update row Post-Database-Commit Post-Forms-Commit Finish More Records More Blocks http://ebiztechnics.blogspot.com
  7. 7. Commit Triggers • Pre-Commit: Fires once if form changes are made or uncommitted changes are posted • Pre- and Post-DML • On-DML: Fires per record, replacing default DML on row Use DELETE_RECORD, INSERT_RECORD, UPDATE_RECORD built-ins http://ebiztechnics.blogspot.com
  8. 8. Commit Triggers • Post-Forms-Commit: Fires once even if no changes are made • Post-Database-Commit: Fires once even if no changes are made Note: A commit-trigger failure causes a rollback to the savepoint. http://ebiztechnics.blogspot.com
  9. 9. Usage of Commit Triggers Pre-Commit Pre-Delete Pre-Insert Pre-Update Check user authorization; set up special locking Journaling; implement foreign-key delete rule Generate sequence numbers; journaling; automatically generated columns; check constraints Journaling; implement foreign-key update rule; auto-generated columns; check constraints http://ebiztechnics.blogspot.com
  10. 10. Usage of Commit Triggers On-Insert/Update/Delete Post-Forms-Commit Post-Database-Commit Replace default block DML statements Check complex multirow constraints Test commit success; test uncommitted posts http://ebiztechnics.blogspot.com
  11. 11. Update Processing ColumnItem Query Rollback Data 20 20 Locked Query Commit 30 30 30 20Update record in form [Save] 30 20[Save] Pre-Update 30 20Pre-Update Row Updated 30 30 20Row updated Post-Update 30 30 20Post-Update http://ebiztechnics.blogspot.com
  12. 12. Pre-Delete Trigger • Check Before Deletion DECLARE CURSOR empcur IS SELECT ’x’ FROM dept WHERE deptno = :emp.deptno; BEGIN OPEN empcur; FETCH empcur INTO :GLOBAL.x; IF empcur%FOUND THEN CLOSE C1; MESSAGE(’There are employees in this dept..can not delete’); RAISE form_trigger_failure; ELSE CLOSE empcur; END IF; END; http://ebiztechnics.blogspot.com
  13. 13. Assigning Sequence Nos. • Pre-Insert Trigger SELECT empseq.nextval INTO :emp.empno FROM dual; Note: Sequence value will be visible after committing, because Pre-Insert trigger fires after committing. http://ebiztechnics.blogspot.com
  14. 14. Keeping an Audit Trail • Write changes to nonbase tables. • Gather statistics on applied changes. Post-Insert example: :GLOBAL.total_ins:= TO_CHAR(TO_NUMBER(:GLOBAL.total_ins)+1); http://ebiztechnics.blogspot.com
  15. 15. Test the success of DMLs • SQL%FOUND • SQL%NOTFOUND • SQL%ROWCOUNT UPDATE ……. SET….. WHERE …..; IF SQL%NOTFOUND THEN MESSAGE(’Record does not exists’); RAISE form_trigger_failure; END IF; http://ebiztechnics.blogspot.com
  16. 16. DML Statements Issued During Commit Processing INSERT INTO base_table (base_column, base_column,...) VALUES (:base_item, :base_item, ...) UPDATE base_table SET base_column = :base_item, base_column = :base_item, ... WHERE ROWID = :ROWID DELETE FROM base_table WHERE ROWID = :ROWID http://ebiztechnics.blogspot.com
  17. 17. DML Statements Issued During Commit Processing Rules: • DML statements may fire database triggers. • Form Builder uses and retrieves ROWID. • The Update Changed Columns Only and Enforce Column Security properties affect UPDATE statements. • Locking statements are not issued. http://ebiztechnics.blogspot.com
  18. 18. Overriding default transaction On-Check-Unique On-Column-Security On-Commit On-Rollback On-Savepoint On-Sequence-Number CHECK_RECORD_UNIQUENESS ENFORCE_COLUMN_SECURITY COMMIT_FORM ISSUE_ROLLBACK ISSUE_SAVEPOINT GENERATE_SEQUENCE_NUMBER Trigger Do-the-Right-Thing Built-in On-Logon On-Logout LOGON LOGOUT Transactional Triggers For Logging on and off http://ebiztechnics.blogspot.com
  19. 19. Commit Status • What is Commit Status? • SYSTEM.RECORD_STATUS: – NEW – INSERT (also caused by control items) – QUERY – CHANGED • SYSTEM.BLOCK_STATUS: – NEW (may contain records with status INSERT) – QUERY (also possible for control block) – CHANGED (block will be committed) http://ebiztechnics.blogspot.com
  20. 20. Commit Status • SYSTEM.FORM_STATUS: – NEW – QUERY – CHANGED • System variables versus built-ins for commit status • Built-ins for getting and setting commit status: – GET_BLOCK_PROPERTY – GET_RECORD_PROPERTY – SET_ RECORD _PROPERTY http://ebiztechnics.blogspot.com
  21. 21. Commit Status • Do not confuse commit status with validation status. • The commit status is updated during validation. IF :SYSTEM.BLOCK_STATUS IN (‘NEW’,’CHANGED’) THEN COMMIT_FORM; END IF; CLEAR_FORM; http://ebiztechnics.blogspot.com
  22. 22. Array DML • Performs array inserts, updates, and deletes • Vastly reduces network traffic Fewer round trips (exact number depends on array size) Empno Ename Job Sal 7369 SMITH CLERK 800 7499 ALLEN SALESMAN 1600 7521 WARD SALESMAN 1250 7566 JONES ANAGER 2975 7654 MARTIN SALESMAN 1250 7698 BLAKE MANAGER 2850 7782 CLARK MANAGER 2450 2 inserts 2 updates 1 delete Database http://ebiztechnics.blogspot.com
  23. 23. Effect of Array DML on Transactional Triggers Array DML Size = 1 Array DML Size > 1 Fires Fires for each insert, update, delete Fires for each insert, update, delete Repeated for each insert, update, delete POST- PRE- DML Fires DML POST- PRE- http://ebiztechnics.blogspot.com
  24. 24. Implementing Array DML 1. Enable the Array Processing option. 2. Specify a DML Array Size of greater than 1. 3. Specify block primary keys. http://ebiztechnics.blogspot.com
  25. 25. Summary • Post and commit phases • Flow of commit processing • DML statements issued during commit processing • Characteristics and common uses of commit triggers • Overriding default transaction processing • Getting and setting the commit status • Implementing Array DML http://ebiztechnics.blogspot.com

×