1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu overview of PL / SQL pptx

18 283 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 112,22 KB

Nội dung

Overview of PL/SQL 18 Introduction to Oracle: SQL and PL/SQL Using Procedure Builder18Ć2 Schedule: Timing Topic 20 minutes Lecture 20 minutes Total Overview of PL/SQL 18Ć3 Objectives This lesson provides an overview of how to create and use PL/SQL program units and subprograms using Oracle Procedure Builder. At the end of this lesson, you should be able to D Determine the benefits of accessing the Oracle7 database with PL/SQL. D Describe basic PL/SQL program constructs. D Describe the Oracle Procedure Builder tool. Introduction to Oracle: SQL and PL/SQL Using Procedure Builder18Ć4 Technical Note: Examples of procedural programming languages are C and FORTRAN, which are considered 3GLs. Procedural languages afford direct control over processing; the programmer must encode exactly how a particular operation is to be done. SQL is non-procedural and a 4GL. Non-procedural languages are generally easier to use, but at the expense of processing control. The programmer states the database operation that needs to be done, and the Oracle7 Server determines how to do it. PL/SQL is a hybrid language that uses SQL to access the database, but allows explicit processing control on top of SQL. Therefore, PL/SQL affords the best of both worlds. Overview of PL/SQL 18Ć5 Overview What Is PL/SQL? PL/SQL (Procedural Language/SQL) is an extension to SQL, incorporating many of the design features of programming languages of recent years. It allows the data manipulation and query statements of SQL to be included within block-structured and procedural units of code, making PL/SQL a powerful transaction processing language. Benefits from PL/SQL You can take advantage of the procedural capabilities of PL/SQL, which are unavailable in SQL. Modularize Program Development D Group logically related statements within blocks. D Nest sub-blocks inside larger blocks to build powerful programs. D Break down a complex problem into a set of manageable, well-defined, logical modules, and implement them with blocks. Declare Identifiers D Declare variables, constants, cursors, and exceptions, and then use them in SQL and procedural statements. D Declare variables belonging to simple and composite datatypes. D Declare variables dynamically based upon the data structure of tables and columns in the database. Program with Procedural Language Control Structures D Execute a sequence of statements conditionally. D Execute a sequence of statements iteratively in a loop. D Process individually the rows returned by a multiple-row query with an explicit cursor. D Combine PL/SQL with Oracle tools, such as Developer/2000 Forms, to group associated commands together to control execution. Handle Errors D Process Oracle7 Server errors with exception handling routines. D Declare user-defined error conditions and process them with exception handling routines. Continued Introduction to Oracle: SQL and PL/SQL Using Procedure Builder18Ć6 Overview of PL/SQL 18Ć7 Overview continued Benefits of PL/SQLĊcontinued Portability D Since PL/SQL is native to Oracle, you can move programs to any host environment that supports Oracle and PL/SQL. D You can also move code between the Oracle7 Server and your application environment using Procedure Builder’s drag-and-drop capabilities. Integration D PL/SQL plays a central role to both the Oracle7 Server (through stored procedures, database triggers, and packages) and Oracle development tools (through Developer/2000 component triggers). D Variables and datatypes in PL/SQL and SQL are compatible. Therefore, PL/SQL bridges the gap between convenient access to database technology and the need for procedural programming capabilities. Improve Performance D PL/SQL can improve the performance of an application. The benefits differ depending upon the execution environment. D PL/SQL groups SQL statements together within a single block and sends the entire block to the server in a single call, therefore reducing network traffic. Introduction to Oracle: SQL and PL/SQL Using Procedure Builder18Ć8 Overview of PL/SQL 18Ć9 PL/SQL Block Structure A basic PL/SQL block of code can contain up to three parts. The order in which the sections of the blocks are written is shown below. Section Description Inclusion Declarative Contains all variables, constants, cursors, and user-defined exceptions that will be referenced within the Executable section. Optional Executable Contains SQL statements to manipulate data in the database and PL/SQL statements to manipulate data in the block. Mandatory Exception Handling Specifies the actions to perform when errors and abnormal conditions arise within the Executable section. Optional Note: In PL/SQL, an error or warning is called an exception. Section keywords DECLARE, BEGIN, and EXCEPTION are not followed by semicolons. However, END and all other PL/SQL statements do require a semicolon to terminate the statement. You can string statements together on the same line. However, this method is not recommended for clarity or editing. Introduction to Oracle: SQL and PL/SQL Using Procedure Builder18Ć10 Class Management Note: In the classroom, the database uses PL/SQL version 2.3, while Procedure Builder uses PL/SQL version 1.5. Some apparent differences are datatypes, comparison operators, and composite datatypes. [...].. .PL/ SQL Block Structure continued Every unit of PL/ SQL comprises one or more blocks These blocks can be entirely separate or nested one within another Therefore, one block can represent a small part of another block, which in turn can be part of the whole unit of code PL/ SQL Program Constructs The following list outlines a variety of different PL/ SQL program constructs using the basic PL/ SQL block... return values Developer/2000 components allow you to declare procedures and functions as part of the application (a form or report), and call them from other procedures, functions, and triggers Overview of PL/ SQL 18Ć13 18Ć14 Introduction to Oracle: SQL and PL/ SQL Using Procedure Builder The PL/ SQL Environment PL/ SQL is not an Oracle product in its own right; it is a technology employed by the Oracle7... Oracle tools Blocks of PL/ SQL are passed to and processed by a PL/ SQL engine, which may reside within the tool or within the Oracle7 Server The engine used depends on where the PL/ SQL is being invoked PL/ SQL Engine at the Oracle7 Server When you submit blocks from a Pro* program, user-exit, SQL* Plus, or Server Manager, the PL/ SQL engine in the Oracle7 Server processes them It breaks the SQL within the block... ClientĆServer PL/ SQL Development Application partitioning through Procedure Builder is available to assist you with distribution of logic between client and server Users can drag and drop a PL/ SQL program unit between the client and the server Class Management Note: Oracle Procedure Builder is sold with Developer/2000 or as a separate product Overview of PL/ SQL 18Ć17 18Ć18 Introduction to Oracle: SQL and PL/ SQL. .. done at the application site, not at the server site Overview of PL/ SQL 18Ć15 18Ć16 Introduction to Oracle: SQL and PL/ SQL Using Procedure Builder About Procedure Builder Oracle Procedure Builder is a tool you can use to create, execute, and debug PL/ SQL programs used in your application tools, such as a form or a report, or on the Oracle7 Server through its graphical interface Integrated PL/ SQL Development... Unnamed PL/ SQL block that is embedded within an application or is issued interactively All PL/ SQL environments Stored Procedure or Named PL/ SQL block that can Function accept parameters and can be invoked repeatedly Oracle7 Server with Procedural Extension Application Procedure or Function Named PL/ SQL block that can accept parameters and can be invoked repeatedly Components of Developer/2000, for example... application event and is fired automatically Components of Developer/2000, for example Forms Note: A function is similar to a procedure, except that a function must return a value Overview of PL/ SQL 18Ć11 18Ć12 Introduction to Oracle: SQL and PL/ SQL Using Procedure Builder PL/ SQL Block Structure continued The two types of constructs covered in this course are anonymous blocks and subprograms Anonymous... Named PL/ SQL module that Oracle7 Server with groups together related procedures, Procedural Extension functions, and identifiers Database Trigger PL/ SQL block that is associated with a database table and is fired automatically Oracle7 Server with Procedural Extension Application Trigger PL/ SQL block that is associated with an application event and is fired automatically Components of Developer/2000,... number of memory cursors required Note: Procedures and functions declared as part of a Developer/2000 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 Application subprograms pass blocks to that application’s local PL/ SQL. .. unnamed blocks They are declared at the point in an application where they are to be executed and are passed to the PL/ SQL engine for execution at runtime You can embed an anonymous block within a precompiler program and within SQL* Plus or Server Manager Triggers in Developer/2000 components consist of such blocks Subprograms Subprograms are named PL/ SQL blocks You can declare them either as procedures . best of both worlds. Overview of PL/ SQL 18Ć5 Overview What Is PL/ SQL? PL/ SQL (Procedural Language /SQL) is an extension to SQL, incorporating many of the. Oracle: SQL and PL/ SQL Using Procedure Builder18Ć6 Overview of PL/ SQL 18Ć7 Overview continued Benefits of PL/ SQL continued Portability D Since PL/ SQL is

Ngày đăng: 24/01/2014, 10:20

TỪ KHÓA LIÊN QUAN