Pages

Cheat sheet PLSQL Package

#what is a pl/sql package?
-schema object that groups logically related pl/sql TYPES, ITEMS, AND SUBPROGRAMS.
-packages have two parts
-- specification
-- body
--sometimes body is unnecessary
--specification (spec) is the interface to your application
--it declares the types, variables, constants, exceptions, cursors, and subprograms available for use.
-- body defines cursors and subprograms, implements the spec

CREATE [OR REPLACE] PACKAGE package_name
  [AUTHID {CURRENT_USER | DEFINER}]
  {IS | AS}
  [PRAGMA SERIALLY_REUSABLE;]
  [collection_type_definition ...]
  [record_type_definition ...]
  [subtype_definition ...]
  [collection_declaration ...]
  [constant_declaration ...]
  [exception_declaration ...]
  [object_declaration ...]
  [record_declaration ...]
  [variable_declaration ...]
  [cursor_spec ...]
  [function_spec ...]
  [procedure_spec ...]
  [call_spec ...]
  [PRAGMA RESTRICT_REFERENCES(assertions) ...]
END [package_name];

[CREATE [OR REPLACE] PACKAGE BODY package_name {IS | AS}
  [PRAGMA SERIALLY_REUSABLE;]
  [collection_type_definition ...]
  [record_type_definition ...]
  [subtype_definition ...]
  [collection_declaration ...]
  [constant_declaration ...]
  [exception_declaration ...]
  [object_declaration ...]
  [record_declaration ...]
  [variable_declaration ...]
  [cursor_body ...]
  [function_spec ...]
  [procedure_spec ...]
  [call_spec ...]
[BEGIN
  sequence_of_statements]
END [package_name];]

##Advantages of PL/SQL Packages
-modularity
-easier application design
-information hiding
-added Functionality


No comments:

Post a Comment

If you like to say anything (good/bad), Please do not hesitate...