BC remote Oracle DBA - Call (800) 766-1884  
Oracle Consulting Oracle Training Development

Remote DBA

Remote DBA Plans  

Remote DBA Service

Remote DBA RAC

   
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 

Remote DBA services

Remote DBA Support

Remote DBA RAC

Remote DBA Reasons

Remote Oracle Tuning

Remote DBA Links

Oracle DBA Support

Oracle DBA Forum

Oracle Disaster

Oracle Training

Oracle Tuning

Oracle Training

 Remote DBA SQL Server

Remote MSSQL Consulting

Oracle DBA Hosting

Oracle License Negotiation

 

 


 

 

 

 

 
 

EnterpriseDB: Stored Procedures

Oracle Tips by Burleson Consulting
 

A stored procedure is procedural code that is compiled and stored in the database.  You call the stored procedure from other stored procedures, client applications or from SQL.  Chapter 4, Programming in EnterpriseDB, will go into tremendous detail of EnterpriseDB's procedural language, SPL and will touch briefly on creating stored procedures in several other languages that are available inside EnterpriseDB.

PROCEDUREs, FUNCTIONs and PACKAGEs are all collectively called "stored procedures".  A more accurate name might be "stored code" but for some reason they have always been called "stored procedures".

CREATE PROCEDURE/FUNCTION/PACKAGE

Because I will be going into so much more detail in the next chapter, I will just show some very basic SPL syntax examples here.

Here is a function that returns the string, 'Hello World'.

CREATE OR REPLACE FUNCTION make_output RETURN VARCHAR2 AS
BEGIN
  RETURN 'Hello World';
END;

And here is a procedure that calls the make_output function defined above and displays it to the terminal.

CREATE OR REPLACE PROCEDURE do_output AS
BEGIN
  DBMS_OUTPUT.put_line( make_output );
END;

Here is a package that combines the above two stored procedures into a single package.

CREATE OR REPLACE PACKAGE my_output_maker AS
  FUNCTION make_output RETURN VARCHAR2;
  PROCEDURE do_output;
END;

CREATE OR REPLACE PACKAGE BODY my_output_maker AS
  FUNCTION make_output RETURN VARCHAR2 AS
  BEGIN
    RETURN 'Hello World';
  END;
  PROCEDURE do_output AS
  BEGIN
    DBMS_OUTPUT.put_line( make_output );
  END;
END;

ALTER FUNCTION

You can alter a function to rename it or assign a new owner but it is normally easier to just recreate the function.

GRANT PROCEDURE/FUNCTION/PACKAGE

You can grant execute on functions, procedures or packages to allow someone to run them.

GRANT EXECUTE ON make_output TO BOB;
GRANT EXECUTE ON do_output TO JSCHMOE;
GRANT EXECUTE ON my_output_maker() TO BILL;

You do not need to grant execute on the individual functions and procedures in a package.  Grant execute on the package and all functions and procedures will be executable by the user.

REVOKE PROCEDURE/FUNCTION/PACKAGE

Revoke works like it does on most everything else.

REVOKE EXECUTE ON FUNCTION make_output FROM BOB;
REVOKE EXECUTE ON PROCEDURE do_output FROM JSCHMOE;
REVOKE EXECUTE ON PACKAGE my_output_maker FROM BILL;

DROP PROCEDURE/FUNCTION/PACKAGE

You can drop a stored procedure using the DROP command.

DROP PROCEDURE do_output;
DROP FUNCTION make_output;
DROP PACKAGE my_output_maker;




This is an excerpt from the book "EnterpriseDB: The Definitive Reference" by Rampant TechPress.


Expert Remote DBA

BC is America's oldest and largest Remote DBA Oracle support provider.  Get real Remote DBA experts, call
BC Remote DBA today.

 

 

Remote DBA Service
 

Oracle Tuning Book

 

Advance SQL Tuning Book 

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

 

 

 

 

 

 

BC Remote Oracle Support

Remote DBA

Remote DBA Services

Copyright © 1996 -  2013 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.



Hit Counter