Presentation is loading. Please wait.

Presentation is loading. Please wait.

PL/SQL and the Table API. Benefits of Server-Side Code Speedy Pizza MENU NAPOLITAINE PIZZA Reduced network traffic Maintainability Data integrity Triggers.

Similar presentations


Presentation on theme: "PL/SQL and the Table API. Benefits of Server-Side Code Speedy Pizza MENU NAPOLITAINE PIZZA Reduced network traffic Maintainability Data integrity Triggers."— Presentation transcript:

1 PL/SQL and the Table API

2 Benefits of Server-Side Code Speedy Pizza MENU NAPOLITAINE PIZZA Reduced network traffic Maintainability Data integrity Triggers Procedures Functions Packages

3 Older Editions of Designer Most constraints only enforced in application Server vulnerable to other access methods Application code references tables and generates network traffic

4 Database Trigger NOT a form trigger –When-enter-block, When-validate-item… Occurs in server Associated with Lock or DB modification Before or After DB event For every affected Row, or For SQL Statement

5 What Is a Database Trigger? ITEMS DML action Database Trigger Code that is implicitly executed when an INSERT, UPDATE, or DELETE statement is issued against its associated table or view When –Before DML –After DML What –Row –Statement Trigger

6 Triggers and Packages Triggers often call procedures in Packages Packages provide Scope for Variables shared by Procedures Each process gets own copy of Package Variables

7 RENTALS Public Definitions Packages 1 + 1 2 Procedures Functions Public and Private Elements Body Action Value = 2 Specification

8 PL/SQL in the Repository APPLICATION[1] Relational Table Definitions PL/SQL Definitions PL/SQL Composition Navigator - Server Model Server ModelDistribution Triggers Functions Procedures Triggers Packages Structure Implementation

9 PL/SQL Definitions Function Definitions Package Definitions Procedure Definitions Cursor Definitions Trigger Definitions Undefined PL/SQL Server Model Arguments Sub Program Units Program Data Datastructures Synonyms P_SET_PRICE CREATE... ( p_name IN VARCHAR2) IS v_date DATE; TYPE table_type IS... BEGIN IF... THEN... ;... callprocedure(v_date);... END;

10 Navigator - Server Model PL/SQL Definitions PL/SQL Composition Server Model Relational Table Definitions APPLICATION[1] TITLES Triggers TRIG1 Columns Trigger Logic TRIG1 PL/SQL Definitions Trigger Definitions Trigger Header Definition PL/SQL Definition Complete Enabled Trigger... When Condition... PL/SQL Block... PL/SQL Logic Defining Triggers

11 PL/SQL Definitions Procedure Definitions P_SET_PRICE Navigator - Server Model Opening the Logic Editor Drag the definition to the work surface

12 Using the Logic Editor PROCEDURE PL/SQL PROCEDURE Select INTO FROM WHERE SELECT title INTO v_title FROM titles WHERE product_code = p_product_code;... SELECT Outliner Text Editor PL/SQL Root Constructs Statements Static Data Construct Tree

13 Generating PL/SQL Objects DDL file: CREATE OR REPLACE statements Header Data declarations PL/SQL logic Use the utility as you would for other database objects

14 Fortunately... You do not have to write most triggers or packages Designer writes them for you You give specifications You generate Table API All this code used to be in Applications

15 Table API Keeps Applications Thin Application Validation code Application Tables Table API Tables

16 Table API Triggers Triggers Fire on insert, update, or delete Call the server packages

17 Table API Packages Are called by: –Applications –Triggers Perform DML operations Validate data Derive column values Server Packages

18 Package cg$titles Insert Update Delete Lock procedures... call cg$titles.ins Insert TITLES # * PROD_CDE * TITLE... TITLES # * PROD_CDE * TITLE... In- sert trigger

19 Why API? Table API provides a Table Handler for each package Normal DML causes Triggers to Invoke Handlers Applications can call API procedures directly –Disabling recursive call of trigger

20 Applications and the API TABLE Column_1 Column_2 Server Packages Form Builder application Triggers WebServer application

21 Customization API handles many standard Requirements. You can add code to API for special Requirements. Even specify whether it is called before or after standard handling.


Download ppt "PL/SQL and the Table API. Benefits of Server-Side Code Speedy Pizza MENU NAPOLITAINE PIZZA Reduced network traffic Maintainability Data integrity Triggers."

Similar presentations


Ads by Google