Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL proc and select statement
A copy of this was sent to "Benjamin R Heath" <benheath_at_uswest.net>
(if that email address didn't require changing)
On Thu, 18 Nov 1999 07:04:43 -0600, you wrote:
>Thomas Kyte wrote in message ...
>>A copy of this was sent to Alex Rivlin <rivlin_at_122.net>
>>(if that email address didn't require changing)
>>On Tue, 16 Nov 1999 22:18:20 -0800, you wrote:
>>
>>>I have a select statement that I execute from the OCI -based client.
>>>Rather then building "select * from dual" (real select is lot more
>>>complex than that - about 30 lines )
>>>in the client, I'd like to put it in procedure and call the procedure
>>>from the client. That will allow me to change logic in select without
>>>updating client programs.
>>>How can I create a procedure for that? If I can not, what would be an
>>>alternative?
>>>In sybase or MSSQL I could do the following:
>>>create proc A_Proc as select * from dual;
>>>In oracle I get an error: "INTO is required for this select statement"
>>>What would be the way to do it in Oracle?
>>>
>>>Alex
>>
>>
>>see the web site in my URL and read the HOWTO on returning result sets from
>>stored procedures. The feature you are looking for is called a ref cursor.
>>
>>--
>>See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to
>Oracle8i'...
>>Current article is "Part I of V, Autonomous Transactions" updated June
>21'st
>>
>>Thomas Kyte tkyte_at_us.oracle.com
>>Oracle Service Industries Reston, VA USA
>>
>>Opinions are mine and do not necessarily reflect those of Oracle
>Corporation
>
>I've been converting from Sybase to Oracle and have a number of stored
>procedures that return a record set as described above. Someone suggested
>using a view instead of a stored procedure that opens a ref cursor. What
>are the advantages/disadvantages to this apporach?
>
>
>
If you can do it in a view -- by all means, do it in a view. A view is more accessible to more tools in more ways then result sets from stored procedures.
One advantage of the procedures over views is security. I can look at WHO is asking WHAT question (and maybe log that info) and then open a cursor for them. A view is a little more open.
So, if you can do it in a view, and that doesn't comprimise your security, go for it (you cannot ad-hoc a result set from a stored procedure -- you get what you get. you can more easily ad-hoc a view and do different things with it)
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Nov 18 1999 - 08:42:23 CST
![]() |
![]() |