Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATERI PL/SQL Procedures Functions Packages Database Triggers

Similar presentations


Presentation on theme: "MATERI PL/SQL Procedures Functions Packages Database Triggers"— Presentation transcript:

1 MATERI PL/SQL Procedures Functions Packages Database Triggers
Oracle Developer

2 PL/SQL Introduction

3 About PL/SQL PL/SQL is the procedural extension to SQL with design features of programming langguages DML and query statements of SQL are included within procedural units of code

4 PL/SQL Environment PL/SQL engine PL/SQL PL/SQL Block PL/SQL Block
Procedural Statement Executor SQL Oracle Server SQL statement executor

5 Benefits of PL/SQL Integration Application Oracle Server
PL/SQL plays a central role to both the Oracle Server (through stored procedures, stored functions, database triggers, and packages) and Oracle development tools (through Oracle Developer component triggers). Oracle Developer applications make use of shared libraries that hold code (procedures and functions) and can be accessed locally or remotely. Oracle Developer consists of Oracle Forms, Oracle Reports, and Oracle Graphics. SQL datatypes can also be used in PL/SQL. Combined with the direct access that SQL provides, these shared datatypes integrate PL/SQL with the Oracle Server data dictionary. PL/SQL bridges the gap between convenient access to database technology and the need for procedural programming capabilities. PL/SQL in Oracle Tools Many Oracle tools, including Oracle Developer, have their own PL/SQL engine, which is independent of the engine present in the Oracle Server. The engine filters out SQL statements and sends them individually to the SQL statement executor in the Oracle Server. It processes the remaining procedural statements in the procedural statement executor, which is in the PL/SQL engine. The procedural statement executor processes data that is local to the application (that is already inside the client environment, rather than the database). This reduces work sent to the Oracle Server and the number of memory cursors required. Oracle Server Shared library

6 Benefits of PL/SQL Improved Performance Other DBMSs Application SQL
IF...THEN ELSE END IF; Oracle with PL/SQL Improved Performance PL/SQL can improve the performance of an application. The benefits differ depending on the execution environment. PL/SQL can be used to group SQL statements together within a single block and to send the entire block to the server in a single call, thereby reducing networking traffic. Without PL/SQL, the SQL statements would be processed one at a time. Each SQL statement results in another call to the Oracle Server and higher performance overhead. In a networked environment, the overhead can become significant. As the slide illustrates, if your application is SQL intensive, you can use PL/SQL blocks and subprograms to group SQL statements before sending them to the Oracle Server for execution. PL/SQL can also cooperate with Oracle Server application development tools such as Oracle Developer Forms and Reports. By adding procedural processing power to these tools, PL/SQL boosts performance. Note: Procedures and functions declared as part of a Developer application are distinct from those stored in the database, although their general structure is the same. Stored subprograms are database objects and are stored in the data dictionary. They can be accessed by any number of applications, including Developer applications. Application

7 Modularize program development
Benefits of PL/SQL Modularize program development DECLARE BEGIN EXCEPTION Benefits of PL/SQL You can take advantage of the procedural capabilities of PL/SQL, which are not available in SQL. PL/SQL Block Structure Every unit of PL/SQL comprises one or more blocks. These blocks can be entirely separate or nested one within another. The basic units (procedures, functions, and anonymous blocks) that make up a PL/SQL program are logical blocks, which can contain any number of nested subblocks. Therefore, one block can represent a small part of another block, which in turn can be part of the whole unit of code. Modularized Program Development Group logically related statements within blocks. Nest subblocks inside larger blocks to build powerful programs. Break down a complex problem into a set of manageable, well-defined, logical modules and implement the modules with blocks. Place reusable PL/SQL code in libraries to be shared between Oracle Developer applications or store it in an Oracle Server to make it accessible to any application that can interact with an Oracle database. END;

8 Benefits of PL/SQL It is portable. You can declare identifiers.
You can program with procedural language control structures. It can handle errors. Portability Because PL/SQL is native to the Oracle Server, you can move programs to any host environment (operating system or platform) that supports the Oracle Server and PL/SQL. In other words, PL/SQL programs can run anywhere the Oracle Server can run; you do not need to tailor them to each new environment. You can also move code between the Oracle Server and your application. You can write portable program packages and create libraries that can be reused in different environments. Identifiers Declare variables, cursors, constants, and exceptions and then use them in SQL and procedural statements. Declare variables belonging to scalar, reference, composite, and large object (LOB) datatypes. Declare variables dynamically based on the data structure of tables and columns in the database.

9 Benefits of Subprograms
Easy maintenance Improved data security and integrity Improved Performance Improved code clarity

10 Invoking Subprograms LOG_EXECUTION procedure PROCEDURE leave_emp
Developer Portal Discoverer Another Proc. or Functions iSQL*Plus


Download ppt "MATERI PL/SQL Procedures Functions Packages Database Triggers"

Similar presentations


Ads by Google