Get full name package : Utility Package « Function Procedure Packages « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Function Procedure Packages » Utility Package 
27. 27. 5. Get full name package
SQL>
SQL> CREATE OR REPLACE PACKAGE errpkg
  2  IS
  3     PROCEDURE record_and_stop;
  4
  5  END errpkg;
  6  /

Package created.

SQL>
SQL>
SQL> CREATE TABLE employee (
  2  employee_id NUMBER(38,0)
  3  ,deptno NUMBER(3,0NOT NULL
  4  ,first_name  VARCHAR2(95NOT NULL
  5  ,last_name   VARCHAR2(95NOT NULL
  6  ,salary NUMBER(11,2)
  7  );

Table created.

SQL>
SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE employee_pkg
  2  AS
  3     SUBTYPE fullname_t IS VARCHAR2 (200);
  4
  5     FUNCTION fullname (l  employee.last_name%TYPE,f  employee.first_name%TYPE)
  6        RETURN fullname_t;
  7
  8     FUNCTION fullname (employee_id_in IN employee.employee_id%TYPE)
  9        RETURN fullname_t;
 10  END employee_pkg;
 11  /

Package created.

SQL>
SQL> CREATE OR REPLACE PACKAGE BODY employee_pkg
  2  AS
  3     FUNCTION fullname (l employee.last_name%TYPE,f employee.first_name%TYPE)
  4        RETURN fullname_t
  5     IS
  6     BEGIN
  7        RETURN    l || ',' || f;
  8     END;
  9
 10     FUNCTION fullname (employee_id_in IN employee.employee_id%TYPE)
 11        RETURN fullname_t
 12     IS
 13        retval   fullname_t;
 14     BEGIN
 15        SELECT fullname (last_name, first_nameINTO retval
 16          FROM employee
 17         WHERE employee_id = employee_id_in;
 18
 19        RETURN retval;
 20     EXCEPTION
 21        WHEN NO_DATA_FOUND THEN RETURN NULL;
 22
 23        WHEN TOO_MANY_ROWS THEN errpkg.record_and_stop;
 24     END;
 25  END employee_pkg;
 26  /

SP2-0810: Package Body created with compilation warnings

SQL>
SQL>
SQL>
SQL>
SQL> DECLARE
  2     l_name employee_pkg.fullname_t;
  3     employee_id_in CONSTANT PLS_INTEGER := 1;
  4  BEGIN
  5     l_name := employee_pkg.fullname (employee_id_in);
  6
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
27. 27. Utility Package
27. 27. 1. Timer package
27. 27. 2. Match a date format
27. 27. 3. Validate all objects in a schema
27. 27. 4. Process date value
27. 27. 5. Get full name package
27. 27. 6. Product check
27. 27. 7. Check the code version
27. 27. 8. Audit package
27. 27. 9. Create a package to handle display, update, delete and insert operations
27. 27. 10. Counter package
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.