|
|
|
|
Re: What is Stored Procedure [message #599156 is a reply to message #599149] |
Tue, 22 October 2013 11:06 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Michel Cadot wrote on Tue, 22 October 2013 10:58
There is no difference (until 12c), stored is there in the opposite of anonymous PL/SQL block which is not stored.
You don't need 12 to have a stored procedure that is not stored in database. Just declare it in an anonymous block. But in all the cases stored procedure is stored - what changes is scope. If stored procedure is declared at database level you can reference it anywhere you want and Oracle will find it (since it is stored in database it is always available). If stored procedure is declared in an anonymous block you can reference it anywhere within that block (and all its inner blocks). If it is created in WITH clause, you can reference it anywhere within that SQL statement.
SY.
|
|
|
|
|
Re: What is Stored Procedure [message #599162 is a reply to message #599159] |
Tue, 22 October 2013 12:20 |
|
Michel Cadot
Messages: 68641 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Stored procedure:
QL> create or replace procedure p is begin null; end;
2 /
Procedure created.
SQL> exec p;
PL/SQL procedure successfully completed.
Not stored procedure (as er Solomon's remark):
SQL> declare
2 procedure p2 is begin null; end;
3 begin
4 p2;
5 p;
6 end;
7 /
PL/SQL procedure successfully completed.
But now:
SQL> exec p2;
BEGIN p2; END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'P2' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
[Updated on: Tue, 22 October 2013 12:20] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: What is Stored Procedure [message #599239 is a reply to message #599232] |
Wed, 23 October 2013 03:19 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
jgjeetu wrote on Wed, 23 October 2013 08:41 i am not able to understand why did he put "end;" before begin . This has already been explained by LF
Quote:procedure p2 is begin null; end;
- this is a "private" procedure (private that this anonymous PL/SQL block). It does nothing (NULL), but the basic syntax is satisfied - it has its name, begin and end, and at least one command in between.
Quote:if i get the syntax then i will be able to understand it properly. Thanks
declare
--local procedure declaration
procedure procname (parameters) is
--variable declarations
begin
statements;
end;
begin
statements;
end;
|
|
|
|