Connecting Tech Pros Worldwide Help | Site Map

PL/SQL-PROCEDURES - 1

  #1  
Old May 30th, 2007, 07:27 AM
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,485
PROCEDURE:-IT IS A COMPILED BLOCK OF CODE WHICH IS STORED AS AN OBJECT WITHIN THE DATABASE. IT MAY OR MAY NOT RETURN ANY VALUE OR MIGHT RETURN MORE THAN ONE VALUE.

syntax
------------
CREATE [OR REPLACE] PROCEDURE PROCEDURENAME([PARAMETER PARAMETER MODE DATATYPE [,PARAMETER...,....]])
{IS/AS}
[LOCAL DECLARATION];
BEGIN
EXECUTABLE STATMENT;
[EXCEPTION
EXCEPTION HANDLER]
END [PROCEDURENAME];

SAMPLE EXAMPLE TO SHOW PARAMETER LESS PROCEDURE
==================================================
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE list_tables AS
  2. BEGIN
  3. dbms_output.put_line('These are the tables you own:');
  4. FOR item IN (SELECT table_name FROM user_tables)
  5. LOOP
  6. dbms_output.put_line(item.table_name);
  7. END LOOP;
  8. END;
  9.  

Parameters
===========
1.formal---declared In The Defination Of The Procedure.they Receive The Value.
2.actual---passed Within Parenthesis,to Execute The Procedure.

Parameter Mode--it Specifies What Can Be Done With The Parameters.

In/out/in Out
------------------------

In--(default)-it Lets To Pass A Value To The Subprogram Being Called.the Value Can't Be Changed Inside The Subprogram.it Is Like A Constant.it Can't Be Assigned Any Value.

Out--it Lets The Subprogram Pass A Value To The Caller.inside The Subprogram The Out Parameter Is An Un-initialised Variable.
Subprogram Has To Place A Value In The Out Parameter. What Ever Changes Are Made To The Out Parameter Are Made Available To The Actual Parameter.the Actual Parameter Corresponding To The Out Parameter Must Be A Variable.

In Out--it Is Same As In And Out Both Together.it Can Get A Value From The Calling Procedure And Can Return A Value To The Calling Procedure.the Value Of This Type Of Paramater Can Be Used In Subprogram And The Actual Parameter Must Be An Initialised Variable.


Also check PL/SQL-PROCEDURES - 2



  #2  
Old February 20th, 2008, 10:50 AM
Newbie
 
Join Date: Feb 2008
Posts: 2

re: PL/SQL-PROCEDURES - 1


can any 1 tell me advantages of using stored procedures in postgresql.........
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for authoritative reference on PL/SQL grammar Ira Baxter answers 3 June 27th, 2008 07:55 PM
COLUMN WITH WORD_WRAP IN PL/SQL ???? george lewycky answers 5 June 27th, 2008 06:38 PM
Oracle PL/SQL 9i/10g - Introduction debasisdas insights 0 May 10th, 2007 06:16 AM
Looking for authoritative reference on PL/SQL grammar Ira Baxter answers 3 July 19th, 2005 11:20 PM
Running PL/SQL scripts from PHP Dung Nguyen answers 3 July 17th, 2005 03:41 AM