Selecting from a stored proc [message #312854] |
Wed, 09 April 2008 23:07  |
witchfindergeneral
Messages: 2 Registered: April 2008
|
Junior Member |
|
|
Hi all,
how do you write a simple stored procedure to return a result set? e.g.
create or replace tst as
begin
select * from ...
end;
Can I then simply issue a select * from tst?
|
|
|
|
|
Re: Selecting from a stored proc [message #312872 is a reply to message #312854] |
Thu, 10 April 2008 00:32   |
ap_karthi
Messages: 87 Registered: October 2007 Location: Bangalore
|
Member |
|
|
You need to declare cursor to select all the columns, so better try in a simple way as shown below
create or replace tst as
a varchar2(50)
begin
select ename into a from emp where empno = 7788;
dbms_output.put_line('The employee name is '||ename);
end;
|
|
|
Re: Selecting from a stored proc [message #312876 is a reply to message #312872] |
Thu, 10 April 2008 00:43   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
ap_karthi wrote on Thu, 10 April 2008 07:32 | You need to declare cursor to select all the columns, so better try in a simple way as shown below
create or replace tst as
a varchar2(50)
begin
select ename into a from emp where empno = 7788;
dbms_output.put_line('The employee name is '||ename);
end;
|
Except that this does in no way comply to the requirements.
|
|
|
|
Re: Selecting from a stored proc [message #312953 is a reply to message #312878] |
Thu, 10 April 2008 03:41   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Michel Cadot wrote on Thu, 10 April 2008 06:44 | 1/ It is not fornatted
2/ It does not answer the question
Better think before replying.
|
It is also syntactically incorrect, and would not compile at all, never mind compile with errors.
|
|
|
|
Re: Selecting from a stored proc [message #313156 is a reply to message #312984] |
Thu, 10 April 2008 22:37   |
witchfindergeneral
Messages: 2 Registered: April 2008
|
Junior Member |
|
|
Thanks for the replies. Im not asking for a complete solution, just some advice.
I take it you can't issue this :
create or replace procedure test is
begin
select * from mytable;
end;
Cool, thats all I needed to know. It's for implementation within a crystal report btw.
|
|
|
|