Free Powerpoint Templates Page 1 Free Powerpoint Templatesبسم الله الرحمن الرحيم عدد الساعات: 2 نظري+2عملي الرمز:314 حسب المتطلبات:223 حسب (مبادئ قواعد.

Slides:



Advertisements
Similar presentations
PL/SQL Agenda: Basic PL/SQL block structure
Advertisements

LOCKS Locks are mechanisms used to ensure data integrity while allowing maximum concurrent access to data. Oracle's locking is fully automatic and requires.
Exception Handling in PL/SQL. POINTS TO DISCUSS What is Exception Handling Structure of Exception Handling Section Types of Exceptions.
1 CONCURRENCY CONTROL IN ORACLE Users manipulate Oracle table data via SQL or PL/SQL sentences. An Oracle transaction can be made up of a single SQL. sentence.
PL/SQL block has the following structure: DECLARE Declaration statements BEGIN Executable statements EXCEPTION Exception-handling statements END ;
Introduction to PL/SQL. Procedural Language extension for SQL Oracle Proprietary 3GL Capabilities Integration of SQL Portable within Oracle data bases.
Bordoloi and Bock CURSORS. Bordoloi and Bock CURSOR MANIPULATION To process an SQL statement, ORACLE needs to create an area of memory known as the context.
PL / SQL P rocedural L anguage / S tructured Q uery L anguage Chapter 7 in Lab Reference.
Bordoloi and Bock EXCEPTIONS. Bordoloi and Bock Errors Two types of errors can be found in a program: compilation errors and runtime errors. There is.
Cursor and Exception Handling By Nidhi Bhatnagar.
Oracle10g Developer: PL/SQL Programming1 Objectives Manipulating data with cursors Managing errors with exception handlers Addressing exception-handling.
Chapter 4 Cursors and Exception Handling Oracle10g Developer:
Exceptions Oracle Database PL/SQL 10g Programming Chapter 7.
EE Copyright س Oracle Corporation, All rights reserved. ® Review of PL/SQL.
Lecture 4 PL/SQL language. PL/SQL – procedural SQL Allows combining procedural and SQL code PL/SQL code is compiled, including SQL commands PL/SQL code.
INTRODUCTION TO PL/SQL. Class Agenda Introduction Introduction to PL/SQL Declaring PL/SQL Variable Creating the Executable Section Interacting with the.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
University of Sunderland COM 220 Lecture Six Slide 1 Building Interactive Forms Applications using Oracle.
Overview · What is PL/SQL · Advantages of PL/SQL · Basic Structure of a PL/SQL Block · Procedure · Function · Anonymous Block · Types of Block · Declaring.
PL/SQL A BRIEF OVERVIEW DAVID WILSON. PL/SQL User’s Guide and Reference PL/SQL User’s Guide and Reference.
L/O/G/O Working with Composite Data Types. Objectives After completing this lesson, you should be able to do the following: –Create user-defined PL/SQL.
CS178 Database Management PL/SQL session 8 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman.
CSIT 313 DB PROGRAMMING EXCEPTION HANDLING. In PL/SQL, an error condition is called an exception. An exception can be either –internally defined (by the.
PL / SQL By Mohammed Baihan. What is PL/SQL? PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
Trapping Oracle Server Exceptions. 2 home back first prev next last What Will I Learn? Describe and provide an example of an error defined by the Oracle.
PL/SQL Block Structure DECLARE - Optional Variables, cursors, user-defined exceptions BEGIN - Mandatory SQL Statements PL/SQL Statements EXCEPTIONS - Optional.
PL/SQL Declaring Variables PL/SQL Block Structure DECLARE (Optional) Variables, cursors, user-defined exceptions BEGIN (Mandatory) - SQL statements -
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Database Management COP4540, SCS, FIU Oracle PL/SQL (Ch 10.5)
Handling Exceptions. 2 home back first prev next last What Will I Learn? Describe several advantages of including exception handling code in PL/SQL Describe.
Oracle 8i Exception Handling. General Syntax DECLARE --- BEGIN --- EXCEPTION WHEN exception_name1 THEN -Error handling statements WHEN exception_name2.
Using SQL in PL/SQL ITEC 224 Database Programming.
PL/SQLPL/SQL Oracle11g: PL/SQL Programming Chapter 4 Cursors and Exception Handling.
1 Handling Exceptions Part F. 2 Handling Exceptions with PL/SQL What is an exception? Identifier in PL/SQL that is raised during execution What is an.
Chapter 16 Cursors and Exceptions. Chapter Objectives  Determine when an explicit cursor is required  Declare, open, and close an explicit cursor 
DATABASE PROGRAMS CS 260 Database Systems. Overview  Introduction  Anonymous blocks  Oracle’s PL/SQL language basics  Conditions and loops  Cursors.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Creating Functions. V 12 NE - Oracle 2006 Overview of Stored Functions A function is a named PL/SQL block that returns a value A function can be stored.
Chapter 18: Exception Handling1 Chapter Eighteen Exception Handling Objective: – Define exceptions – List types of exception handlers – Trap errors – Exception.
Handling Exceptions. Objectives What is exception Types of exceptions How to handle exceptions Trapping pre defined oracle errors.
Oracle10g Developer: PL/SQL Programming1 Objectives Named program units How to identify parameters The CREATE PROCEDURE statement Creating a procedure.
Copyright  Oracle Corporation, All rights reserved. 23 Handling Exceptions.
Introduction to PL/SQL Francis Thottungal. The outline The basic PL/SQL code structure is : DECLARE -- optional, which declares and define variables,
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Overview.
DB Programming Course Lecture 4. Errors Two types of errors can be found in a program: compilation errors and runtime errors. There is a special section.
1 Copyright © 2004, Oracle. All rights reserved. PL/SQL Programming Concepts: Review.
ITEC 224 Database Programming
CHAPTER 5 EXCEPTION HANDLING
Oracle11g: PL/SQL Programming Chapter 5 Procedures.
Program with PL/SQL Lesson 4.
Interacting with the Oracle Server
Interacting with the Oracle Server
Handling Exceptions.
Oracle11g: PL/SQL Programming Chapter 2 Basic PL/SQL Block Structures.
Oracle11g: PL/SQL Programming Chapter 4 Cursors and Exception Handling.
Oracle9i Developer: PL/SQL Programming Chapter 3 PL/SQL Processing.
Handling Exceptions.
Database Programming PL SQL.
SQL PL/SQL Presented by: Dr. Samir Tartir
Database Management Systems 2
PL/SQL Scripting in Oracle:
Handling Exceptions.
Handling Exceptions.
Database Management Systems 2
Handling Exceptions.
PL/SQL Declaring Variables.
«Болашақтың есігін ашатын бес кілттің бірі – білім ошақтары».
Database Programming Using Oracle 11g
Database Programming Using Oracle 11g
Presentation transcript:

Free Powerpoint Templates Page 1 Free Powerpoint Templatesبسم الله الرحمن الرحيم عدد الساعات: 2 نظري+2عملي الرمز:314 حسب المتطلبات:223 حسب (مبادئ قواعد البيانات) أستاذات/المادة: م. لندا عمر البدري - م. نجلاء حسن

Page 2 Free Powerpoint Templates التعامل مع الأخطاء Exceptions Handling تطبيق PL/SQL المحاضرة السابعة

Free Powerpoint Templates Page 3 In PL/SQL, an error condition is called an exception. 1.أخطاء معرفة من قبل الأوراكل (Pre-defined /Internally defined exceptions are implicitly raised ). 2.أخطاء معرفة بواسطة المستخدم (User defined exceptions are explicitly raised ; by using the RAISE statement ) Introduction to exceptions

Free Powerpoint Templates Page 4 أخطاء معرفة من قبل الأوراكل (Pre-defined exceptions)

Free Powerpoint Templates Page 5

Free Powerpoint Templates Page 6 مثال Declare Erec emp%rowtype; Begin Select * into Erec from emp where ename =‘Ahmed ’; DBMS_OUTPUT.PUT_LINE(Erec.job||’ ‘||Erec.sal); Exception When no_data_found then DBMS_OUT_LINE(‘No such employee exists in the table’); End; /

Free Powerpoint Templates Page 7 To handle all the other errors that have not been defined in the block ‘OTHERS’ exception can be used. يتم معالجة الأخطاء التي لم تذكر داخل الوحدة البرمجية باستخدام ‘OTHERS’ exception. مثال : Exception when NO_DATA_FOUND then DBMS_OUTPUT.PUT_LIN When OTHERS then Statements; END;

Free Powerpoint Templates Page 8 الحالة «OTHERS exception handler» تكتب دائماً أخر حالة لمعالجة الاخطاء في ال Block ، The optional OTHERS exception handler is always the last handler in the block; it acts as the handler for all exceptions the block does. أى وحدة برمجية (Block) يمكن أن تحتوي على حالة “Other” واحدة فقط. The block can have only one OTHERS handler. يمكن لأكثر من حالة خطأ (exceptions) أن تتم معالجتها باستخدام نفس الجمل (statement) ، وفي هذه الحالة يتم كتابة جميع الحالات في جملة When ويتم الفصل بينهم باستخدام OR كما في المثال التالي : If two or more exceptions are to be executed in the same sequence of statements, list the exception names in the WHEN clause, separating them by the keyword OR, as in the following example:

Free Powerpoint Templates Page 9 Exception when NO_DATA_FOUND or TOO_MANY_ROWS Then Statements to handle these errors When OTHERS then statements END; Example

Free Powerpoint Templates Page 10 أخطاء معرفة بواسطة المستخدم User defined exceptions يمكن التصريح عن ال User – defined exception كالتالي : declare past-due exception; acct-num number(5); Begin

Free Powerpoint Templates Page 11 Declarative section Declare Executable sectionException handling section Raise Reference Explicitly raise the exception by using the raise statement Name the exception Handle the raised Exception

Free Powerpoint Templates Page 12 User-Defined Exceptions

Free Powerpoint Templates Page 13 Declare e_invalid_product exception ; Begin Update product Set descrip = Book Where prodid= 1122; If SQL%NOTFOUND then Raise e-invalid-product; Endif ; Commit; Exception When e-invalid-product then DBMS_OUTPUT.PUT_LINE(‘ invalid product number’); END; Example

Free Powerpoint Templates Page 14 يظهر اسم ال exception مرة واحدة فقط في جزء ال exception handler part. يمكن للException handler ان يشير فقط المتغيرات التي تم تعريفها داخل الblock. في حالة وجود Nested block فان ال Block الداخلي يمكنه استخدام الexception handler الخاص بال Block الخارجي كما هو موضح في المثال التالي.

Free Powerpoint Templates Page 15 Declare > Begin Select into…. --Outer block select > Declare Begin Select into …… --inner block select Exception When NO-DATA-FOUND then … END inner-block; Statement; --outer block statements Exception --outer block exception When NO_DATA_FOUND then ……. When TOO_MANY_ROWS then ….. END outer_block; example

Free Powerpoint Templates Page 16 THE END