SlideShare uma empresa Scribd logo
1 de 52
Introduction to Advanced
         PL/SQL
               Presented by
                Vinay Kumar
Overview
•   Fundamentals of PL/SQL
     – Control Structures and other PL/SQL language elements

•   Oracle Types and Collections

•   PL/SQL and Oracle Interaction

•   Subprograms and Packages

•   Error Handling
Fundamentals
•   Building blocks of PL/SQL Code:

     – Identifiers

     – Reserved Words

     – Literals

     – Comments

     – Data types

     – Operators
Fundamentals
Typical PL/SQL code:

Declare

   a integer;
   b varchar2(10);

Begin
   select employee_id
      into a
    from employee_table;

End;
Fundamentals
Datatype Conversions

  – Explicit Conversion

     • To_Char
     • To_Date
     • To_Number
Fundamentals
• Implicit Conversion
  – Example - From CHAR to NUMBER
     DECLARE
           initial_time CHAR(5)
           final_time CHAR(5)
           Time_Diff NUMBER(5)
     BEGIN
           initial_time := to_char(sysdate, ‘SSSSS’);
                      …
           final_time := to_char(sysdate, ‘SSSSS’);
           Time_diff := initial_time – final_time;
     END
Fundamentals
• Declarations
    seconds_per_minute NUMBER := 60;
    elapsed_minutes NUMBER := 20;
    elapsed_seconds NUMBER :=
             elapsed_minutes * seconds_per_minute ;

    minutes_per_hour number DEFAULT 60;
    user_name NOT NULL VARCHAR2(30) := ‘Infosys’;
    order_number order.order_number %TYPE;
    order order%ROWTYPE;
Fundamentals
• Case sensitivity
• Name resolution
• Scope and Visibility
      DECLARE
            x INTEGER;
      BEGIN
            DECLARE
                   y INTEGER;
            BEGIN
                   …
            END;
            …
      END;
Fundamentals
•   LIKE operator
       ename LIKE ‘J%SON’

•   IS NULL operator

•   BETWEEN operator
     – A BETWEEN 1 AND 10

•   IN operator
     – ename in (NULL, ‘KING’, FORD’)

•   Concatenation   operator
     – ‘Suit’ || ‘case’
Fundamentals
• Cursors

  – Work areas

  – Explicit cursors
     • “Points to” the current row of the Result Set
     • Similar to File processing
     DECLARE CURSOR c1 IS SELECT empno, ename, job FROM emp WHERE
       deptno = 20;
     • OPEN, FETCH and CLOSE
Fundamentals
• CURSOR FOR loop

  – Implicitly declares its loop index as a record that
    represents a row fetched from the database

  – Closes cursor at the end of the loop

     DECLARE CURSOR c1 IS SELECT ename, sal, hiredate, deptno   FROM emp; ...
     BEGIN FOR emp_rec IN c1
       LOOP
             ...
             salary_total := salary_total + emp_rec.sal;
       END LOOP;
     END;
Fundamentals
• Cursor Variables
  – unlike a cursor, a cursor variable can be opened for any
    type-compatible query

    PROCEDURE open_cv (generic_cv IN OUT GenericCurTyp,
                          choice NUMBER) IS
    BEGIN
     IF choice = 1 THEN
                 OPEN generic_cv FOR
                          SELECT * FROM emp;
     ELSIF choice = 2 THEN
                 OPEN generic_cv FOR
                          SELECT * FROM dept;
     END IF;
     ...
    END;
Fundamentals
• Ref Cursor

  – A cursor type where you can skip specifying
    Structure, and thus can use the same cursor for
    various structures.

    TYPE my_ref_cur_type IS REF CURSOR;
    my_ref_cursor my_ref_cur_type;
Fundamentals
• Attributes
   – %TYPE
       my_title books.title%TYPE;


   – %ROWTYPE
       DECLARE dept_rec dept%ROWTYPE; -- declare record variable
       my_deptno := dept_rec.deptno;
       DECLARE
               CURSOR c1 IS
                          SELECT ename, sal, hiredate, job FROM emp;
               emp_rec c1%ROWTYPE;
                          -- declare record variable that represents
                           -- a row fetched from the emp table
   FETCH c1 INTO emp_rec;
Fundamentals
• Conditional Control – IF statement
   – If-Then
   – If-Then-Else
   – If-Then-ElsIf

• Iterative Control
   – Loop
   – While-Loop
   – For-Loop
          – EXIT
          – EXIT-WHEN
Fundamentals
• LOOP
   LOOP
    …
   END LOOP;


• WHILE-LOOP
   WHILE a < 10 LOOP
     …
   END LOOP


• FOR-LOOP
   FOR i IN 1..3 [REVERSE] LOOP
    …
   END LOOP;
Fundamentals
DECLARE
       acct_balance NUMBER(11,2);
       acct CONSTANT NUMBER(4) := 3;
       debit_amt CONSTANT NUMBER(5,2) := 500.00;
BEGIN
       SELECT bal INTO acct_balance
       FROM accounts WHERE account_id = acct
       FOR UPDATE OF bal;

        IF acct_balance >= debit_amt THEN
                  UPDATE accounts SET bal = bal - debit_amt
                              WHERE account_id = acct;
        ELSE
                  INSERT INTO temp VALUES (acct, acct_balance,
                               'Insufficient funds');
                   -- insert account, current balance, and message
        END IF;
END;
Fundamentals
• LOOP
 LOOP
   ...
   total := total + salary;
   EXIT WHEN total > 25000; -- exit loop if condition is true
 END LOOP;



• FOR LOOP
     FOR i IN 1..order_qty
     LOOP
               UPDATE sales SET custno = customer_id
                         WHERE serial_num = serial_num_seq.NEXTVAL;
    END LOOP;
Fundamentals
DECLARE
     salary emp.sal%TYPE := 0;
     mgr_num emp.mgr%TYPE;
     last_name emp.ename%TYPE;
     starting_empno emp.empno%TYPE := 7499;
BEGIN
     SELECT mgr INTO mgr_num
     FROM emp WHERE empno = starting_empno;
     WHILE salary <= 2500 LOOP
               SELECT sal, mgr, ename INTO salary, mgr_num,
                       last_name FROM emp WHERE
                       empno = mgr_num;
     END LOOP;
END
Fundamentals
• Sequential Control
   – GOTO statement lets you branch to a label unconditionally
     IF rating > 90 THEN
       GOTO calc_raise; -- branch to label
     END IF;
       ...

     <<calc_raise>>
     IF job_title = 'SALESMAN' THEN -- control resumes here
                   amount := commission * 0.25;
     ELSE
                   amount := salary * 0.10;
     END IF;
Fundamentals
• Modularity
  – PL/SQL Blocks

  – Sub-programs
     • PROCEDURES
     • FUNCTIONS

  – PACKAGES
     • bundle logically related types, variables, cursors, and
       subprograms
Fundamentals
PROCEDURE award_bonus (emp_id NUMBER)
IS
     bonus REAL;
     comm_missing EXCEPTION;
BEGIN
     SELECT comm * 0.15 INTO bonus
     FROM emp WHERE empno = emp_id;
     IF bonus IS NULL THEN
               RAISE comm_missing;
     ELSE
               UPDATE payroll SET pay = pay + bonus WHERE
               empno = emp_id;
     END IF;
     EXCEPTION WHEN comm_missing
     THEN
               ...
END award_bonus;
Fundamentals
CREATE PACKAGE emp_actions AS
     -- package specification
     PROCEDURE hire_employee (empno NUMBER,
                         ename CHAR, ...);
     PROCEDURE fire_employee (emp_id NUMBER);
END emp_actions;

CREATE PACKAGE BODY emp_actions AS -- package body

     PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...) IS
BEGIN
              INSERT INTO emp VALUES (empno, ename, ...);
     END hire_employee;
     PROCEDURE fire_employee (emp_id NUMBER) IS
     BEGIN
              DELETE FROM emp WHERE empno = emp_id;
     END fire_employee;

END emp_actions;
Fundamentals
• RECORD

 – %ROWTYPE attribute is used to declare a record that
   represents a row in a table or a row fetched from a
   cursor.

 – You can create your own customized record types too.
Fundamentals
  Some Oracle Concepts
• TRIGGERS

  – A database trigger is a stored subprogram associated with a table.

  – You can have Oracle automatically fire the trigger before or after
    an INSERT, UPDATE, or DELETE statement affects the table.

  – One of the many uses for database triggers is to audit data
    modifications.
    CREATE TRIGGER audit_sal AFTER UPDATE OF sal ON emp
    FOR EACH ROW
    BEGIN
     INSERT INTO emp_audit VALUES ...
    END;
Fundamentals
•   Constraints
•   Indexes
     – indexes are useful because they sort the table on the indexed columns and
        hence make the search faster
•   Views
     – Views in Oracle are windows to limited data
•   Decode
        SELECT DECODE (A, B, C, D).. means if A = B then C else D
          SELECT DECODE (A, B, C, D, E, F).. means if A = B then C else if A
                   = D then E else F
        CREATE OR REPLACE VIEW <viewname> AS
          (SELECT DECODE(Total, 0, '', Total) Total FROM <tablename>);
Fundamentals
• GOTO usage

  – The control cannot branch off into a IF statement,
    LOOP statement or a sub-block
  – You cannot pass control from IF into ELSE


• NULL statement

  – The NULL statement explicitly specifies inaction
    IF rating > 90 THEN
                 compute_bonus(emp_id);
    ELSE
                 NULL;
    END IF;
Collections
•   - A collection is an ordered group of elements, all of the same
    type.

     – Each element has a unique subscript that determines its
       position in the collection.

     – Collections work like the arrays found in most third-
       generation programming languages. Also, collections can be
       passed as parameters.

     – You can define collection types in a package, then use them
       programmatically in your applications.

     – Single dimensional only
Collections

   – Also, you can pass collections as parameters. So, you
     can use them to move columns of data into and out of
     database tables or between client-side applications and
     stored subprograms. In addition, collections can store
     instances of an object type and can be attributes of an
     object type.


• Two types of collections
   – Items of type TABLE are nested tables
   – Items of type VARRAY are varrays (short for variable-
     size arrays)
Collections
• Nested Tables
  – - database tables that can be stored in a column value
Collections
• Array Vs Nested Table
  •   Varrays have a maximum size, but nested tables do not.

  •   Varrays are always dense, but nested tables can be sparse.

  •   Oracle stores varray data in-line (in the same table) unless it exceeds 4K, in which
      case the data is stored out-of-line. But, Oracle stores nested table data out-of-line in
      a store table, which is a system-generated database table associated with the nested
      table.

  •   When stored in the database, varrays retain their ordering and subscripts, but nested
      tables do not.
Collections
• When to use what?
  – A varray is stored as an object, whereas a nested table
    is stored in a storage table with every element mapped
    to a row in the table. So, if you want efficient queries,
    use nested tables.

  – If you want to retrieve entire collection as a whole, use
    varrays. However, when collections get very large, it
    becomes impractical. So, varrays are better suited for
    small collections.
Collections

Creating Arrays and Nested tables
   CREATE TYPE address_type AS OBJECT
                                  (house_number NUMBER,
                                 city VARCHAR2(10),
                                 phone_number NUMBER);

   CREATE TYPE address_list_array AS VARRAY(4) OF address_type;

   CREATE TYPE address_list_ntable AS TABLE OF address_type;
(An object table is a special kind of table in which each row represents an object)

   CREATE TABLE customer (customer_number NUMBER,
                      date_of_joining DATE,
                       address_list address_list_ntable)
             NESTED TABLE address_list STORE AS address_list_ntable_values;
Collections
   Accessing Contents of Varrays

                   EXISTS
IF courses.EXISTS(i) THEN courses(i) := new_course; END IF;
                   COUNT
                   LIMIT
                   FIRST and LAST
                   PRIOR and NEXT
                   EXTEND
                   TRIM
                   DELETE
Collections
Accessing Nested Table contents
SELECT * FROM EMPLOYEES;
NAME
--------------------
ADDR(HOUSE, STREET, STATE)
---------------------------------------------------------------------
HOWARD ROGERS
ADDR_TABLE(ADDRESS('16 BRADEY AVENUE', 'HAMMONDVILLE', 'NSW'),
     ADDRESS('4 JULIUS AVENUE',
'CHATSWOOD', 'NSW'))

SELECT E.NAME,A.HOUSE,A.STREET,A.STATE
     2 FROM EMPLOYEES E, TABLE(E.ADDR)(+) A;
NAME HOUSE STREET STATE
--------------- ------------------------- -------------------- -----
HOWARD ROGERS 16 BRADEY AVENUE HAMMONDVILLE NSW
HOWARD ROGERS 4 JULIUS AVENUE CHATSWOOD NSW
Collections
Manipulating Varray elements
 SET SERVEROUTPUT ON SIZE 1000000
 DECLARE
     TYPE table_type IS VARRAY(5) OF NUMBER(10);
      v_tab table_type;
     v_idx NUMBER;
 BEGIN
     -- Initialise the collection with two values.
     v_tab := table_type(1, 2);
 -- Extend the collection with extra values.

  << load_loop >>
    FOR i IN 3 .. 5
                      LOOP
                                   v_tab.extend;
                                   v_tab(v_tab.last) := i;
                      END LOOP load_loop;
    -- Can't delete from a VARRAY.
    -- v_tab.DELETE(3);
    -- Traverse collection
    v_idx := v_tab.FIRST;

    << display_loop >>
    WHILE v_idx IS NOT NULL
                    LOOP
                                   DBMS_OUTPUT.PUT_LINE('The number ' || v_tab(v_idx));
                                   v_idx := v_tab.NEXT(v_idx);
                      END LOOP display_loop;
    END;
Collections
• Manipulating Nested Table data
        INSERT INTO EMPLOYEES VALUES (
'HOWARD ROGERS',
ADDR_TABLE(
ADDRESS ('16 BRADEY AVENUE','HAMMONDVILLE','NSW'),
ADDRESS ('4 JULIUS AVENUE','CHATSWOOD','NSW'))
);

UPDATE TABLE(SELECT ADDR FROM EMPLOYEES WHERE NAME='HOWARD ROGERS')
SET HOUSE = '15 BRADEY AVENUE'
WHERE HOUSE = '16 BRADEY AVENUE';

DELETE FROM
TABLE(SELECT ADDR FROM EMPLOYEES WHERE NAME='HOWARD ROGERS')
WHERE STREET = 'CHATSWOOD';
Collections
• Records
  – A record is a group of related data items stored
    in fields, each with its own name and datatype

  DECLARE
    TYPE StockItem IS RECORD ( item_no INTEGER(3) NOT NULL :=
    999, description VARCHAR2(50), quantity INTEGER, price
    REAL(7,2)); ...
  BEGIN
     ...
  END;
Oracle – PL/SQL Interaction
Oracle – PL/SQL
• A transaction is a series of SQL data manipulation
  statements that does a logical unit of work. For example,
  two UPDATE statements might credit one bank account
  and debit another

• aggregate functions: AVG, COUNT, GROUPING, MAX,
  MIN, STDDEV, SUM, and VARIANCE. Except for
  COUNT(*), all aggregate functions ignore nulls

• SQL pseudocolumns: CURRVAL, NEXTVAL, ROWID,
  and ROWNUM

• A sequence is a schema object that generates sequential
  numbers
Oracle – PL/SQL

•   Cursor Example
     DECLARE
         my_sal emp.sal%TYPE;
         my_job emp.job%TYPE;
         factor INTEGER := 2;
         CURSOR c1 IS SELECT factor*sal FROM emp WHERE job = my_job;

       BEGIN
                 ...
                 OPEN c1; -- here factor equals 2
                 LOOP
                         FETCH c1 INTO my_sal;
                         EXIT WHEN c1%NOTFOUND;
                         factor := factor + 1; -- does not affect FETCH
                 END LOOP;
       END;
Subprograms and Packages
• Packages

  – The specification is the interface to your
    applications; it declares the types, constants,
    variables, exceptions, cursors, and subprograms
    available for use.

  – The body defines cursors and subprograms and
    so implements the specification.
Subprograms and Packages
•   Packages

    – Only the declarations in the package specification are visible and
      accessible to applications

    – Implementation details in the package body are hidden and
      inaccessible.

    – Packages can be compiled and stored in an Oracle database, where
      their contents can be shared by many applications. When you call
      a packaged subprogram for the first time, the whole package is
      loaded into memory. So, subsequent calls to related subprograms
      in the package require no disk I/O. Thus, packages can enhance
      productivity and improve performance
Subprograms and Packages
• Subprograms are named PL/SQL blocks that
  can take parameters and be invoked. PL/SQL
  has two types of subprograms called
  procedures and functions
• extensibility
• modularity
• reusability
• maintainability
• abstraction
Subprograms and Packages
PROCEDURE raise_salary
     (emp_id INTEGER, amount REAL)
IS
     current_salary REAL;
     salary_missing EXCEPTION;
BEGIN
     SELECT sal INTO current_salary FROM emp WHERE
     empno = emp_id;
     IF current_salary IS NULL THEN
               RAISE salary_missing;
     ELSE UPDATE emp SET sal = sal + amount WHERE
     empno = emp_id;
     END IF;
     EXCEPTION WHEN NO_DATA_FOUND THEN
               INSERT INTO emp_audit VALUES (emp_id, 'No such number');
     WHEN salary_missing
               THEN INSERT INTO emp_audit VALUES (emp_id, 'Salary is
     null');
END raise_salary;
Subprograms and Packages
•   FUNCTION sal_ok (salary REAL,
                title VARCHAR2)
                RETURN BOOLEAN
    IS
        min_sal REAL;
        max_sal REAL;
    BEGIN
        SELECT losal, hisal INTO min_sal, max_sal
        FROM sals WHERE job = title;
        RETURN (salary >= min_sal) AND (salary <= max_sal);
    END sal_ok;
Subprograms and Packages
CREATE PACKAGE emp_actions
   AS -- package spec
   PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2, ...);
   PROCEDURE fire_employee (emp_id INTEGER);
   PROCEDURE raise_salary (emp_id INTEGER, amount REAL);
          ...
END emp_actions;
CREATE PACKAGE BODY emp_actions AS -- package body
   PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2, ...) IS
   BEGIN ...
          INSERT INTO emp VALUES (emp_id, name, ...);
   END hire_employee;
   PROCEDURE fire_employee (emp_id INTEGER) IS
   BEGIN
          DELETE FROM emp WHERE empno = emp_id;
   END fire_employee;
   PROCEDURE raise_salary (emp_id INTEGER, amount REAL) IS
   BEGIN
          UPDATE emp SET sal = sal + amount WHERE empno = emp_id;
   END raise_salary;
   ...
END emp_actions;
Error Handling
•   When an error occurs, an exception is raised

•   raise_application_error(error_number, message);

     DECLARE
       out_of_stock EXCEPTION;
       number_on_hand NUMBER(4);
       BEGIN
                ...
                IF number_on_hand < 1 THEN RAISE
                        out_of_stock;
                END IF;
                EXCEPTION WHEN out_of_stock THEN
                -- handle the error
       END;
Error Handling – example 1
Error Handling – example 2
Error Handling – example 3
Thank You!

Mais conteúdo relacionado

Mais procurados

1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideSrinimf-Slides
 
Oracle APEX Cheat Sheet
Oracle APEX Cheat SheetOracle APEX Cheat Sheet
Oracle APEX Cheat SheetDimitri Gielis
 
Oracle Collections
Oracle CollectionsOracle Collections
Oracle CollectionsTrendz Lab
 
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...rehaniltifat
 
Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joinsredro
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handlingSmitha Padmanabhan
 
Oracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switchingOracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switchingSmitha Padmanabhan
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)Ishucs
 
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Thuan Nguyen
 

Mais procurados (20)

Oracle: Control Structures
Oracle: Control StructuresOracle: Control Structures
Oracle: Control Structures
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Oracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step GuideOracle PLSQL Step By Step Guide
Oracle PLSQL Step By Step Guide
 
Oracle APEX Cheat Sheet
Oracle APEX Cheat SheetOracle APEX Cheat Sheet
Oracle APEX Cheat Sheet
 
ORACLE PL/SQL
ORACLE PL/SQLORACLE PL/SQL
ORACLE PL/SQL
 
Oracle Collections
Oracle CollectionsOracle Collections
Oracle Collections
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
03 Writing Control Structures, Writing with Compatible Data Types Using Expli...
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joins
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Oracle PL/SQL exception handling
Oracle PL/SQL exception handlingOracle PL/SQL exception handling
Oracle PL/SQL exception handling
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
Plsql
PlsqlPlsql
Plsql
 
Oracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switchingOracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switching
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01
 
Unit 4 plsql
Unit 4  plsqlUnit 4  plsql
Unit 4 plsql
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 

Destaque

SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2Dan D'Urso
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online TrainingOracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Trainingsuresh
 
Sql basics
Sql basicsSql basics
Sql basicsKumar
 
Plsql quick guide
Plsql quick guidePlsql quick guide
Plsql quick guide1bi08me024
 
Oracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guideOracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guidebupbechanhgmail
 
Introduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminIntroduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminDrake Huang
 
pl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgepl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgeMasood Khan
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projectsjwjablonski
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture NotesJasour Obeidat
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Thuan Nguyen
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisDan D'Urso
 
AIN100B Microsoft Access Level 2
AIN100B Microsoft Access Level 2AIN100B Microsoft Access Level 2
AIN100B Microsoft Access Level 2Dan D'Urso
 
AIN102 Microsoft Access Queries
AIN102 Microsoft Access QueriesAIN102 Microsoft Access Queries
AIN102 Microsoft Access QueriesDan D'Urso
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQLDan D'Urso
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignDan D'Urso
 
AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1Dan D'Urso
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL CollectionsSteven Feuerstein
 

Destaque (20)

SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2SQL212.2 Introduction to SQL using Oracle Module 2
SQL212.2 Introduction to SQL using Oracle Module 2
 
Oracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online TrainingOracle PL/SQL online training | PL/SQL online Training
Oracle PL/SQL online training | PL/SQL online Training
 
Sql basics
Sql basicsSql basics
Sql basics
 
Plsql quick guide
Plsql quick guidePlsql quick guide
Plsql quick guide
 
Exercise 6
Exercise 6Exercise 6
Exercise 6
 
Sql basics
Sql basicsSql basics
Sql basics
 
Oracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guideOracle database 12c 2 day + performance tuning guide
Oracle database 12c 2 day + performance tuning guide
 
Introduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdminIntroduction to MySQL and phpMyAdmin
Introduction to MySQL and phpMyAdmin
 
pl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledgepl/sql online Training|sql online Training | iTeknowledge
pl/sql online Training|sql online Training | iTeknowledge
 
Adbms lab manual
Adbms lab manualAdbms lab manual
Adbms lab manual
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
Advanced Database Lecture Notes
Advanced Database Lecture NotesAdvanced Database Lecture Notes
Advanced Database Lecture Notes
 
Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05Oracle - Program with PL/SQL - Lession 05
Oracle - Program with PL/SQL - Lession 05
 
AIN106 Access Reporting and Analysis
AIN106 Access Reporting and AnalysisAIN106 Access Reporting and Analysis
AIN106 Access Reporting and Analysis
 
AIN100B Microsoft Access Level 2
AIN100B Microsoft Access Level 2AIN100B Microsoft Access Level 2
AIN100B Microsoft Access Level 2
 
AIN102 Microsoft Access Queries
AIN102 Microsoft Access QueriesAIN102 Microsoft Access Queries
AIN102 Microsoft Access Queries
 
SQL302 Intermediate SQL
SQL302 Intermediate SQLSQL302 Intermediate SQL
SQL302 Intermediate SQL
 
SQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL DesignSQL200A Microsoft Access SQL Design
SQL200A Microsoft Access SQL Design
 
AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1AIN100A Microsoft Access Level 1
AIN100A Microsoft Access Level 1
 
All About PL/SQL Collections
All About PL/SQL CollectionsAll About PL/SQL Collections
All About PL/SQL Collections
 

Semelhante a Advanced PL/SQL Fundamentals and Collections

Semelhante a Advanced PL/SQL Fundamentals and Collections (20)

PL_SQL - II.pptx
PL_SQL - II.pptxPL_SQL - II.pptx
PL_SQL - II.pptx
 
PL-SQL.pdf
PL-SQL.pdfPL-SQL.pdf
PL-SQL.pdf
 
PLSQL (1).ppt
PLSQL (1).pptPLSQL (1).ppt
PLSQL (1).ppt
 
Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06Oracle - Program with PL/SQL - Lession 06
Oracle - Program with PL/SQL - Lession 06
 
Plsql
PlsqlPlsql
Plsql
 
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
 
Oracle - Program with PL/SQL - Lession 04
Oracle - Program with PL/SQL - Lession 04Oracle - Program with PL/SQL - Lession 04
Oracle - Program with PL/SQL - Lession 04
 
plsql les06
 plsql les06 plsql les06
plsql les06
 
L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
Triggers n Cursors.ppt
Triggers n Cursors.pptTriggers n Cursors.ppt
Triggers n Cursors.ppt
 
PLSQL.pptx
PLSQL.pptxPLSQL.pptx
PLSQL.pptx
 
Open Gurukul Language PL/SQL
Open Gurukul Language PL/SQLOpen Gurukul Language PL/SQL
Open Gurukul Language PL/SQL
 
plsql.ppt
plsql.pptplsql.ppt
plsql.ppt
 
Cursor
CursorCursor
Cursor
 
Cursor
CursorCursor
Cursor
 
Introduction to mysql part 3
Introduction to mysql part 3Introduction to mysql part 3
Introduction to mysql part 3
 
Programming in Oracle with PL/SQL
Programming in Oracle with PL/SQLProgramming in Oracle with PL/SQL
Programming in Oracle with PL/SQL
 
Oracle PL/SQL Bulk binds
Oracle PL/SQL Bulk bindsOracle PL/SQL Bulk binds
Oracle PL/SQL Bulk binds
 
PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6PLSQL Coding Guidelines - Part 6
PLSQL Coding Guidelines - Part 6
 
Turbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk ProcessingTurbocharge SQL Performance in PL/SQL with Bulk Processing
Turbocharge SQL Performance in PL/SQL with Bulk Processing
 

Mais de Vinay Kumar

Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Vinay Kumar
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Vinay Kumar
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Vinay Kumar
 
Extend soa with api management Sangam18
Extend soa with api management Sangam18Extend soa with api management Sangam18
Extend soa with api management Sangam18Vinay Kumar
 
Extend soa with api management Doag18
Extend soa with api management Doag18Extend soa with api management Doag18
Extend soa with api management Doag18Vinay Kumar
 
Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Vinay Kumar
 
Extend soa with api management spoug- Madrid
Extend soa with api management   spoug- MadridExtend soa with api management   spoug- Madrid
Extend soa with api management spoug- MadridVinay Kumar
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridVinay Kumar
 
Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Vinay Kumar
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caVinay Kumar
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caVinay Kumar
 
Adf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationAdf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationVinay Kumar
 
Personalization in webcenter portal
Personalization in webcenter portalPersonalization in webcenter portal
Personalization in webcenter portalVinay Kumar
 
Custom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionCustom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionVinay Kumar
 
File upload in oracle adf mobile
File upload in oracle adf mobileFile upload in oracle adf mobile
File upload in oracle adf mobileVinay Kumar
 
Webcenter application performance tuning guide
Webcenter application performance tuning guideWebcenter application performance tuning guide
Webcenter application performance tuning guideVinay Kumar
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperVinay Kumar
 
Oracle adf performance tips
Oracle adf performance tipsOracle adf performance tips
Oracle adf performance tipsVinay Kumar
 
JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - OverviewVinay Kumar
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 

Mais de Vinay Kumar (20)

Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
 
Extend soa with api management Sangam18
Extend soa with api management Sangam18Extend soa with api management Sangam18
Extend soa with api management Sangam18
 
Extend soa with api management Doag18
Extend soa with api management Doag18Extend soa with api management Doag18
Extend soa with api management Doag18
 
Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Roaring with elastic search sangam2018
Roaring with elastic search sangam2018
 
Extend soa with api management spoug- Madrid
Extend soa with api management   spoug- MadridExtend soa with api management   spoug- Madrid
Extend soa with api management spoug- Madrid
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug Madrid
 
Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026ca
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026ca
 
Adf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationAdf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzation
 
Personalization in webcenter portal
Personalization in webcenter portalPersonalization in webcenter portal
Personalization in webcenter portal
 
Custom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionCustom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extension
 
File upload in oracle adf mobile
File upload in oracle adf mobileFile upload in oracle adf mobile
File upload in oracle adf mobile
 
Webcenter application performance tuning guide
Webcenter application performance tuning guideWebcenter application performance tuning guide
Webcenter application performance tuning guide
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paper
 
Oracle adf performance tips
Oracle adf performance tipsOracle adf performance tips
Oracle adf performance tips
 
JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - Overview
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 

Último

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

Advanced PL/SQL Fundamentals and Collections

  • 1. Introduction to Advanced PL/SQL Presented by Vinay Kumar
  • 2. Overview • Fundamentals of PL/SQL – Control Structures and other PL/SQL language elements • Oracle Types and Collections • PL/SQL and Oracle Interaction • Subprograms and Packages • Error Handling
  • 3. Fundamentals • Building blocks of PL/SQL Code: – Identifiers – Reserved Words – Literals – Comments – Data types – Operators
  • 4. Fundamentals Typical PL/SQL code: Declare a integer; b varchar2(10); Begin select employee_id into a from employee_table; End;
  • 5. Fundamentals Datatype Conversions – Explicit Conversion • To_Char • To_Date • To_Number
  • 6. Fundamentals • Implicit Conversion – Example - From CHAR to NUMBER DECLARE initial_time CHAR(5) final_time CHAR(5) Time_Diff NUMBER(5) BEGIN initial_time := to_char(sysdate, ‘SSSSS’); … final_time := to_char(sysdate, ‘SSSSS’); Time_diff := initial_time – final_time; END
  • 7. Fundamentals • Declarations seconds_per_minute NUMBER := 60; elapsed_minutes NUMBER := 20; elapsed_seconds NUMBER := elapsed_minutes * seconds_per_minute ; minutes_per_hour number DEFAULT 60; user_name NOT NULL VARCHAR2(30) := ‘Infosys’; order_number order.order_number %TYPE; order order%ROWTYPE;
  • 8. Fundamentals • Case sensitivity • Name resolution • Scope and Visibility DECLARE x INTEGER; BEGIN DECLARE y INTEGER; BEGIN … END; … END;
  • 9. Fundamentals • LIKE operator ename LIKE ‘J%SON’ • IS NULL operator • BETWEEN operator – A BETWEEN 1 AND 10 • IN operator – ename in (NULL, ‘KING’, FORD’) • Concatenation operator – ‘Suit’ || ‘case’
  • 10. Fundamentals • Cursors – Work areas – Explicit cursors • “Points to” the current row of the Result Set • Similar to File processing DECLARE CURSOR c1 IS SELECT empno, ename, job FROM emp WHERE deptno = 20; • OPEN, FETCH and CLOSE
  • 11. Fundamentals • CURSOR FOR loop – Implicitly declares its loop index as a record that represents a row fetched from the database – Closes cursor at the end of the loop DECLARE CURSOR c1 IS SELECT ename, sal, hiredate, deptno FROM emp; ... BEGIN FOR emp_rec IN c1 LOOP ... salary_total := salary_total + emp_rec.sal; END LOOP; END;
  • 12. Fundamentals • Cursor Variables – unlike a cursor, a cursor variable can be opened for any type-compatible query PROCEDURE open_cv (generic_cv IN OUT GenericCurTyp, choice NUMBER) IS BEGIN IF choice = 1 THEN OPEN generic_cv FOR SELECT * FROM emp; ELSIF choice = 2 THEN OPEN generic_cv FOR SELECT * FROM dept; END IF; ... END;
  • 13. Fundamentals • Ref Cursor – A cursor type where you can skip specifying Structure, and thus can use the same cursor for various structures. TYPE my_ref_cur_type IS REF CURSOR; my_ref_cursor my_ref_cur_type;
  • 14. Fundamentals • Attributes – %TYPE my_title books.title%TYPE; – %ROWTYPE DECLARE dept_rec dept%ROWTYPE; -- declare record variable my_deptno := dept_rec.deptno; DECLARE CURSOR c1 IS SELECT ename, sal, hiredate, job FROM emp; emp_rec c1%ROWTYPE; -- declare record variable that represents -- a row fetched from the emp table FETCH c1 INTO emp_rec;
  • 15. Fundamentals • Conditional Control – IF statement – If-Then – If-Then-Else – If-Then-ElsIf • Iterative Control – Loop – While-Loop – For-Loop – EXIT – EXIT-WHEN
  • 16. Fundamentals • LOOP LOOP … END LOOP; • WHILE-LOOP WHILE a < 10 LOOP … END LOOP • FOR-LOOP FOR i IN 1..3 [REVERSE] LOOP … END LOOP;
  • 17. Fundamentals DECLARE acct_balance NUMBER(11,2); acct CONSTANT NUMBER(4) := 3; debit_amt CONSTANT NUMBER(5,2) := 500.00; BEGIN SELECT bal INTO acct_balance FROM accounts WHERE account_id = acct FOR UPDATE OF bal; IF acct_balance >= debit_amt THEN UPDATE accounts SET bal = bal - debit_amt WHERE account_id = acct; ELSE INSERT INTO temp VALUES (acct, acct_balance, 'Insufficient funds'); -- insert account, current balance, and message END IF; END;
  • 18. Fundamentals • LOOP LOOP ... total := total + salary; EXIT WHEN total > 25000; -- exit loop if condition is true END LOOP; • FOR LOOP FOR i IN 1..order_qty LOOP UPDATE sales SET custno = customer_id WHERE serial_num = serial_num_seq.NEXTVAL; END LOOP;
  • 19. Fundamentals DECLARE salary emp.sal%TYPE := 0; mgr_num emp.mgr%TYPE; last_name emp.ename%TYPE; starting_empno emp.empno%TYPE := 7499; BEGIN SELECT mgr INTO mgr_num FROM emp WHERE empno = starting_empno; WHILE salary <= 2500 LOOP SELECT sal, mgr, ename INTO salary, mgr_num, last_name FROM emp WHERE empno = mgr_num; END LOOP; END
  • 20. Fundamentals • Sequential Control – GOTO statement lets you branch to a label unconditionally IF rating > 90 THEN GOTO calc_raise; -- branch to label END IF; ... <<calc_raise>> IF job_title = 'SALESMAN' THEN -- control resumes here amount := commission * 0.25; ELSE amount := salary * 0.10; END IF;
  • 21. Fundamentals • Modularity – PL/SQL Blocks – Sub-programs • PROCEDURES • FUNCTIONS – PACKAGES • bundle logically related types, variables, cursors, and subprograms
  • 22. Fundamentals PROCEDURE award_bonus (emp_id NUMBER) IS bonus REAL; comm_missing EXCEPTION; BEGIN SELECT comm * 0.15 INTO bonus FROM emp WHERE empno = emp_id; IF bonus IS NULL THEN RAISE comm_missing; ELSE UPDATE payroll SET pay = pay + bonus WHERE empno = emp_id; END IF; EXCEPTION WHEN comm_missing THEN ... END award_bonus;
  • 23. Fundamentals CREATE PACKAGE emp_actions AS -- package specification PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...); PROCEDURE fire_employee (emp_id NUMBER); END emp_actions; CREATE PACKAGE BODY emp_actions AS -- package body PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...) IS BEGIN INSERT INTO emp VALUES (empno, ename, ...); END hire_employee; PROCEDURE fire_employee (emp_id NUMBER) IS BEGIN DELETE FROM emp WHERE empno = emp_id; END fire_employee; END emp_actions;
  • 24. Fundamentals • RECORD – %ROWTYPE attribute is used to declare a record that represents a row in a table or a row fetched from a cursor. – You can create your own customized record types too.
  • 25. Fundamentals Some Oracle Concepts • TRIGGERS – A database trigger is a stored subprogram associated with a table. – You can have Oracle automatically fire the trigger before or after an INSERT, UPDATE, or DELETE statement affects the table. – One of the many uses for database triggers is to audit data modifications. CREATE TRIGGER audit_sal AFTER UPDATE OF sal ON emp FOR EACH ROW BEGIN INSERT INTO emp_audit VALUES ... END;
  • 26. Fundamentals • Constraints • Indexes – indexes are useful because they sort the table on the indexed columns and hence make the search faster • Views – Views in Oracle are windows to limited data • Decode SELECT DECODE (A, B, C, D).. means if A = B then C else D SELECT DECODE (A, B, C, D, E, F).. means if A = B then C else if A = D then E else F CREATE OR REPLACE VIEW <viewname> AS (SELECT DECODE(Total, 0, '', Total) Total FROM <tablename>);
  • 27. Fundamentals • GOTO usage – The control cannot branch off into a IF statement, LOOP statement or a sub-block – You cannot pass control from IF into ELSE • NULL statement – The NULL statement explicitly specifies inaction IF rating > 90 THEN compute_bonus(emp_id); ELSE NULL; END IF;
  • 28. Collections • - A collection is an ordered group of elements, all of the same type. – Each element has a unique subscript that determines its position in the collection. – Collections work like the arrays found in most third- generation programming languages. Also, collections can be passed as parameters. – You can define collection types in a package, then use them programmatically in your applications. – Single dimensional only
  • 29. Collections – Also, you can pass collections as parameters. So, you can use them to move columns of data into and out of database tables or between client-side applications and stored subprograms. In addition, collections can store instances of an object type and can be attributes of an object type. • Two types of collections – Items of type TABLE are nested tables – Items of type VARRAY are varrays (short for variable- size arrays)
  • 30. Collections • Nested Tables – - database tables that can be stored in a column value
  • 31. Collections • Array Vs Nested Table • Varrays have a maximum size, but nested tables do not. • Varrays are always dense, but nested tables can be sparse. • Oracle stores varray data in-line (in the same table) unless it exceeds 4K, in which case the data is stored out-of-line. But, Oracle stores nested table data out-of-line in a store table, which is a system-generated database table associated with the nested table. • When stored in the database, varrays retain their ordering and subscripts, but nested tables do not.
  • 32. Collections • When to use what? – A varray is stored as an object, whereas a nested table is stored in a storage table with every element mapped to a row in the table. So, if you want efficient queries, use nested tables. – If you want to retrieve entire collection as a whole, use varrays. However, when collections get very large, it becomes impractical. So, varrays are better suited for small collections.
  • 33. Collections Creating Arrays and Nested tables CREATE TYPE address_type AS OBJECT (house_number NUMBER, city VARCHAR2(10), phone_number NUMBER); CREATE TYPE address_list_array AS VARRAY(4) OF address_type; CREATE TYPE address_list_ntable AS TABLE OF address_type; (An object table is a special kind of table in which each row represents an object) CREATE TABLE customer (customer_number NUMBER, date_of_joining DATE, address_list address_list_ntable) NESTED TABLE address_list STORE AS address_list_ntable_values;
  • 34. Collections Accessing Contents of Varrays EXISTS IF courses.EXISTS(i) THEN courses(i) := new_course; END IF; COUNT LIMIT FIRST and LAST PRIOR and NEXT EXTEND TRIM DELETE
  • 35. Collections Accessing Nested Table contents SELECT * FROM EMPLOYEES; NAME -------------------- ADDR(HOUSE, STREET, STATE) --------------------------------------------------------------------- HOWARD ROGERS ADDR_TABLE(ADDRESS('16 BRADEY AVENUE', 'HAMMONDVILLE', 'NSW'), ADDRESS('4 JULIUS AVENUE', 'CHATSWOOD', 'NSW')) SELECT E.NAME,A.HOUSE,A.STREET,A.STATE 2 FROM EMPLOYEES E, TABLE(E.ADDR)(+) A; NAME HOUSE STREET STATE --------------- ------------------------- -------------------- ----- HOWARD ROGERS 16 BRADEY AVENUE HAMMONDVILLE NSW HOWARD ROGERS 4 JULIUS AVENUE CHATSWOOD NSW
  • 36. Collections Manipulating Varray elements SET SERVEROUTPUT ON SIZE 1000000 DECLARE TYPE table_type IS VARRAY(5) OF NUMBER(10); v_tab table_type; v_idx NUMBER; BEGIN -- Initialise the collection with two values. v_tab := table_type(1, 2); -- Extend the collection with extra values. << load_loop >> FOR i IN 3 .. 5 LOOP v_tab.extend; v_tab(v_tab.last) := i; END LOOP load_loop; -- Can't delete from a VARRAY. -- v_tab.DELETE(3); -- Traverse collection v_idx := v_tab.FIRST; << display_loop >> WHILE v_idx IS NOT NULL LOOP DBMS_OUTPUT.PUT_LINE('The number ' || v_tab(v_idx)); v_idx := v_tab.NEXT(v_idx); END LOOP display_loop; END;
  • 37. Collections • Manipulating Nested Table data INSERT INTO EMPLOYEES VALUES ( 'HOWARD ROGERS', ADDR_TABLE( ADDRESS ('16 BRADEY AVENUE','HAMMONDVILLE','NSW'), ADDRESS ('4 JULIUS AVENUE','CHATSWOOD','NSW')) ); UPDATE TABLE(SELECT ADDR FROM EMPLOYEES WHERE NAME='HOWARD ROGERS') SET HOUSE = '15 BRADEY AVENUE' WHERE HOUSE = '16 BRADEY AVENUE'; DELETE FROM TABLE(SELECT ADDR FROM EMPLOYEES WHERE NAME='HOWARD ROGERS') WHERE STREET = 'CHATSWOOD';
  • 38. Collections • Records – A record is a group of related data items stored in fields, each with its own name and datatype DECLARE TYPE StockItem IS RECORD ( item_no INTEGER(3) NOT NULL := 999, description VARCHAR2(50), quantity INTEGER, price REAL(7,2)); ... BEGIN ... END;
  • 39. Oracle – PL/SQL Interaction
  • 40. Oracle – PL/SQL • A transaction is a series of SQL data manipulation statements that does a logical unit of work. For example, two UPDATE statements might credit one bank account and debit another • aggregate functions: AVG, COUNT, GROUPING, MAX, MIN, STDDEV, SUM, and VARIANCE. Except for COUNT(*), all aggregate functions ignore nulls • SQL pseudocolumns: CURRVAL, NEXTVAL, ROWID, and ROWNUM • A sequence is a schema object that generates sequential numbers
  • 41. Oracle – PL/SQL • Cursor Example DECLARE my_sal emp.sal%TYPE; my_job emp.job%TYPE; factor INTEGER := 2; CURSOR c1 IS SELECT factor*sal FROM emp WHERE job = my_job; BEGIN ... OPEN c1; -- here factor equals 2 LOOP FETCH c1 INTO my_sal; EXIT WHEN c1%NOTFOUND; factor := factor + 1; -- does not affect FETCH END LOOP; END;
  • 42. Subprograms and Packages • Packages – The specification is the interface to your applications; it declares the types, constants, variables, exceptions, cursors, and subprograms available for use. – The body defines cursors and subprograms and so implements the specification.
  • 43. Subprograms and Packages • Packages – Only the declarations in the package specification are visible and accessible to applications – Implementation details in the package body are hidden and inaccessible. – Packages can be compiled and stored in an Oracle database, where their contents can be shared by many applications. When you call a packaged subprogram for the first time, the whole package is loaded into memory. So, subsequent calls to related subprograms in the package require no disk I/O. Thus, packages can enhance productivity and improve performance
  • 44. Subprograms and Packages • Subprograms are named PL/SQL blocks that can take parameters and be invoked. PL/SQL has two types of subprograms called procedures and functions • extensibility • modularity • reusability • maintainability • abstraction
  • 45. Subprograms and Packages PROCEDURE raise_salary (emp_id INTEGER, amount REAL) IS current_salary REAL; salary_missing EXCEPTION; BEGIN SELECT sal INTO current_salary FROM emp WHERE empno = emp_id; IF current_salary IS NULL THEN RAISE salary_missing; ELSE UPDATE emp SET sal = sal + amount WHERE empno = emp_id; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO emp_audit VALUES (emp_id, 'No such number'); WHEN salary_missing THEN INSERT INTO emp_audit VALUES (emp_id, 'Salary is null'); END raise_salary;
  • 46. Subprograms and Packages • FUNCTION sal_ok (salary REAL, title VARCHAR2) RETURN BOOLEAN IS min_sal REAL; max_sal REAL; BEGIN SELECT losal, hisal INTO min_sal, max_sal FROM sals WHERE job = title; RETURN (salary >= min_sal) AND (salary <= max_sal); END sal_ok;
  • 47. Subprograms and Packages CREATE PACKAGE emp_actions AS -- package spec PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2, ...); PROCEDURE fire_employee (emp_id INTEGER); PROCEDURE raise_salary (emp_id INTEGER, amount REAL); ... END emp_actions; CREATE PACKAGE BODY emp_actions AS -- package body PROCEDURE hire_employee (emp_id INTEGER, name VARCHAR2, ...) IS BEGIN ... INSERT INTO emp VALUES (emp_id, name, ...); END hire_employee; PROCEDURE fire_employee (emp_id INTEGER) IS BEGIN DELETE FROM emp WHERE empno = emp_id; END fire_employee; PROCEDURE raise_salary (emp_id INTEGER, amount REAL) IS BEGIN UPDATE emp SET sal = sal + amount WHERE empno = emp_id; END raise_salary; ... END emp_actions;
  • 48. Error Handling • When an error occurs, an exception is raised • raise_application_error(error_number, message); DECLARE out_of_stock EXCEPTION; number_on_hand NUMBER(4); BEGIN ... IF number_on_hand < 1 THEN RAISE out_of_stock; END IF; EXCEPTION WHEN out_of_stock THEN -- handle the error END;
  • 49. Error Handling – example 1
  • 50. Error Handling – example 2
  • 51. Error Handling – example 3