Unix Technical Forum

Creating and calling stored procedure

This is a discussion on Creating and calling stored procedure within the Oracle Miscellaneous forums, part of the Oracle Database category; --> I am very new to Oracle and have a simple question, which I can't easy find an answer to ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 12:39 PM
Odd Bjørn Andersen
 
Posts: n/a
Default Creating and calling stored procedure

I am very new to Oracle and have a simple question, which I can't easy find
an answer to in the documentation.

I want to write a simple stored procedure in PL/SQL with one input
parameter, and which returns 1 result set.
That should be very simple, but I can't find any examples for this simple
task in the documentation. Maybe
I haven't looked in the right places :-) Is there anyone who could help me
with an example?

And I also want to call this procedure from SQL*Plus, like this: call (or
execute) schema.proc (param=1) and get something like this in return:

Id Name Address
1 AA Street 1, 12345 Town
2 BB Street 5, 12345 Town
......

Is that possible? And what is the syntax? And what if there are out
parameters, how do I specify them in the call (execute)
statement?

Regards
Odd B Andersen


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 12:39 PM
Michel Cadot
 
Posts: n/a
Default Re: Creating and calling stored procedure


"Odd Bjørn Andersen" <obande@online.no> a écrit dans le message de news: 462f446f$0$90269$14726298@news.sunsite.dk...
|I am very new to Oracle and have a simple question, which I can't easy find
| an answer to in the documentation.
|
| I want to write a simple stored procedure in PL/SQL with one input
| parameter, and which returns 1 result set.
| That should be very simple, but I can't find any examples for this simple
| task in the documentation. Maybe
| I haven't looked in the right places :-) Is there anyone who could help me
| with an example?
|
| And I also want to call this procedure from SQL*Plus, like this: call (or
| execute) schema.proc (param=1) and get something like this in return:
|
| Id Name Address
| 1 AA Street 1, 12345 Town
| 2 BB Street 5, 12345 Town
| .....
|
| Is that possible? And what is the syntax? And what if there are out
| parameters, how do I specify them in the call (execute)
| statement?
|
| Regards
| Odd B Andersen
|
|

http://download-uk.oracle.com/docs/c...5.htm#i1211948

Regards
Michel Cadot


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 12:39 PM
DA Morgan
 
Posts: n/a
Default Re: Creating and calling stored procedure

Odd Bjørn Andersen wrote:
> I am very new to Oracle and have a simple question, which I can't easy find
> an answer to in the documentation.
>
> I want to write a simple stored procedure in PL/SQL with one input
> parameter, and which returns 1 result set.
> That should be very simple, but I can't find any examples for this simple
> task in the documentation. Maybe
> I haven't looked in the right places :-) Is there anyone who could help me
> with an example?
>
> And I also want to call this procedure from SQL*Plus, like this: call (or
> execute) schema.proc (param=1) and get something like this in return:
>
> Id Name Address
> 1 AA Street 1, 12345 Town
> 2 BB Street 5, 12345 Town
> .....
>
> Is that possible? And what is the syntax? And what if there are out
> parameters, how do I specify them in the call (execute)
> statement?
>
> Regards
> Odd B Andersen


http://www.psoug.org
Click on Morgan's Library
Click on REF CURSOR
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 12:39 PM
Rene Nyffenegger
 
Posts: n/a
Default Re: Creating and calling stored procedure

On 2007-04-25, Odd Bjørn Andersen <obande@online.no> wrote:
> I am very new to Oracle and have a simple question, which I can't easy find
> an answer to in the documentation.
>
> I want to write a simple stored procedure in PL/SQL with one input
> parameter, and which returns 1 result set.
> That should be very simple, but I can't find any examples for this simple
> task in the documentation. Maybe
> I haven't looked in the right places :-) Is there anyone who could help me
> with an example?
>
> And I also want to call this procedure from SQL*Plus, like this: call (or
> execute) schema.proc (param=1) and get something like this in return:
>
> Id Name Address
> 1 AA Street 1, 12345 Town
> 2 BB Street 5, 12345 Town
> .....
>
> Is that possible? And what is the syntax? And what if there are out
> parameters, how do I specify them in the call (execute)
> statement?
>
> Regards
> Odd B Andersen



something like (untested):

create procedure p(param in varchar2) as
begin

for r in (select col_1, col_2 from tab where col_3 = param) loop

dbms_output.put_line(r.col_1 || ' ' || r.col_2);

end loop;

end p;
/


See also
http://www.adp-gmbh.ch/blog/2006/01/08.html
http://www.adp-gmbh.ch/blog/2006/03/24.php
http://www.adp-gmbh.ch/blog/2007/04/22.php


--
Rene Nyffenegger
http://www.adp-gmbh.ch
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2008, 12:39 PM
Odd Bjørn Andersen
 
Posts: n/a
Default Re: Creating and calling stored procedure


"Rene Nyffenegger" <rene.nyffenegger@gmx.ch> wrote in message
news:f0oi10$tko$1@klatschtante.init7.net...
> On 2007-04-25, Odd Bjørn Andersen <obande@online.no> wrote:
>> I am very new to Oracle and have a simple question, which I can't easy
>> find
>> an answer to in the documentation.
>>
>> I want to write a simple stored procedure in PL/SQL with one input
>> parameter, and which returns 1 result set.
>> That should be very simple, but I can't find any examples for this simple
>> task in the documentation. Maybe
>> I haven't looked in the right places :-) Is there anyone who could help
>> me
>> with an example?
>>
>> And I also want to call this procedure from SQL*Plus, like this: call (or
>> execute) schema.proc (param=1) and get something like this in return:
>>
>> Id Name Address
>> 1 AA Street 1, 12345 Town
>> 2 BB Street 5, 12345 Town
>> .....
>>
>> Is that possible? And what is the syntax? And what if there are out
>> parameters, how do I specify them in the call (execute)
>> statement?
>>
>> Regards
>> Odd B Andersen

>
>
> something like (untested):
>
> create procedure p(param in varchar2) as
> begin
>
> for r in (select col_1, col_2 from tab where col_3 = param) loop
>
> dbms_output.put_line(r.col_1 || ' ' || r.col_2);
>
> end loop;
>
> end p;
> /
>
>
> See also
> http://www.adp-gmbh.ch/blog/2006/01/08.html
> http://www.adp-gmbh.ch/blog/2006/03/24.php
> http://www.adp-gmbh.ch/blog/2007/04/22.php
>
>
> --
> Rene Nyffenegger
> http://www.adp-gmbh.ch


Thanks to all of you! I will look at the suggestion, and the links.
Hopefully they will help me solve this.

Regards
Odd B Andersen


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com