Documente Academic
Documente Profesional
Documente Cultură
PL/SQL
10-3
Advanced Package Concepts
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 3
Advanced Package Concepts
Purpose
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 4
Advanced Package Concepts
Overloading Subprograms
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 5
Advanced Package Concepts
Overloading Subprograms
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 7
Advanced Package Concepts
Overloading: Example
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 8
Advanced Package Concepts
Overloading Restrictions
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 9
Advanced Package Concepts
Overloading Restrictions
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 10
Advanced Package Concepts
Overloading: Example 2
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11
Advanced Package Concepts
Overloading: Example 3
CREATE OR REPLACE PACKAGE dept_pkg IS
PROCEDURE add_department(p_deptno NUMBER,
p_name VARCHAR2 := 'unknown', p_loc NUMBER := 1700);
PROCEDURE add_department(
p_name VARCHAR2 := 'unknown', p_loc NUMBER := 1700);
END dept_pkg;
PROCEDURE add_department (
p_name VARCHAR2:='unknown', p_loc NUMBER:=1700) IS
BEGIN
INSERT INTO departments (department_id,
department_name, location_id)
VALUES (departments_seq.NEXTVAL, p_name, p_loc);
END add_department;
END dept_pkg;
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 13
Advanced Package Concepts
Overloading: Example 3
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 14
Advanced Package Concepts
Overloading: Example 3
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 15
Advanced Package Concepts
Overloading and the STANDARD Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16
Advanced Package Concepts
Overloading and the STANDARD Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 17
Advanced Package Concepts
Using Forward Declarations
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 18
Advanced Package Concepts
Using Forward Declarations
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 19
Advanced Package Concepts
Using Forward Declarations
PROCEDURE award_bonus(...) IS
BEGIN
calc_rating (...); -- resolved by forward declaration
...
END;
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 20
Advanced Package Concepts
Using Forward Declarations
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 21
Advanced Package Concepts
Using Forward Declarations
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 22
Advanced Package Concepts
Package Initialization Block
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23
Advanced Package Concepts
Package Initialization Block
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 24
Advanced Package Concepts
Bodiless Packages
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 25
Advanced Package Concepts
Bodiless Packages
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 26
Advanced Package Concepts
Bodiless Packages: Example 1
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 27
Advanced Package Concepts
Bodiless Packages: Example 2
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 28
Advanced Package Concepts
Invoking a Bodiless Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 29
Advanced Package Concepts
Invoking a Bodiless Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 30
Advanced Package Concepts
Restrictions on Using Package Functions in
SQL Statements
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 32
Advanced Package Concepts
Package Function in SQL: Example 2
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 33
Advanced Package Concepts
Using a Record Structure as a Parameter
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 35
Advanced Package Concepts
Using a User-defined Type as a Parameter
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 36
Advanced Package Concepts
Using a User-defined Type as a Parameter
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 37
Advanced Package Concepts
Using a User-defined Type as a Parameter
DECLARE
v_emp_dept_rec emp_dept_pkg.ed_type;
BEGIN
emp_dept_pkg.sel_emp_dept(100, v_emprec);
END;
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 38
Advanced Package Concepts
Using an INDEX BY Table of Records in a
Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 39
Advanced Package Concepts
Using an INDEX BY Table of Records in a
Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 40
Advanced Package Concepts
Using an INDEX BY Table of Records in a
Package
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 41
Advanced Package Concepts
Terminology
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 42
Advanced Package Concepts
Summary
PLSQL S10L3 Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 43
Advanced Package Concepts