From Oracle:
“When you declare a cursor variable as the formal parameter of a subprogram that fetches from the cursor variable, you must specify the IN or IN OUT mode. If the subprogram also opens the cursor variable, you must specify the IN OUT mode.”
But, I can code that (only OUT parameter):
create or replace procedure mycur_out(mc OUT mycurpkg.mytypecur) as
begin
open mc for select * from mytable;
end mycur_out;
and works equal to (IN OUT parameter)
create or replace procedure mycur_inout(mc IN OUT mycurpkg.mytypecur)
as
begin
open mc for select * from table10;
end mycur_inout;
Also, It’s work fine with dynamic cursor too:
create or replace procedure mycur_out_ref(mc out mycurpkg.mytyperefcur)
as
begin
open mc for 'select * from table10';
end mycur_out_ref;
I’ve tested the 3 cases directly from oracle and from VB6 with ADO, and no problems.
So, in that cases, is there any difference between IN using just “OUT” and “IN OUT” cursors parameters?
UPDATE
The reason I’m asking:
- We read data using routines similar
to the examples (just open the
cursors). The cursor parameters
always are “IN OUT” (Don’t ask me
why, I’m trying to figure out) - The routines are invoked with ADO/VB6
- Now, we are trying to use some of the routines from JDBC, but the
adapter apparently just accepts OUT
parameters in this cases. - Finally, the main reason, I want to change the cursor parameters on DB
routines to only OUT, but first I
want to know the collaterals effects
of that change.
Thanks!
In the text you quote from the manual, note that it is specifically talking about “a subprogram that fetches from the cursor variable“. None of your examples do this, so the quote is not relevant to them.
However, it nonetheless appears that there’s nothing wrong with using
OUTonly in such a situation, if the subprogram both opens and fetches from the cursor variable:I think the the text is actually trying to make two points that are somewhat independent of each other. Firstly, if you want to pass any already-opened cursor variable into a subprogram, which will fetch from it, the parameter must be declare
INorIN OUT. Secondly, if you want to pass a cursor variable into a subprogram, which will then open it, the parameter must be declaredOUTorIN OUT. This is true regardless of whether you actually care about passing the value of the cursor variable back to the caller:This error can be fixed by changing the parameter mode, but actually it would seem to make more sense to simply make the cursor variable a local variable rather than a parameter.