Home » Developer & Programmer » Forms » invalid cursor in 9i (but works on 11g)
invalid cursor in 9i (but works on 11g) [message #520023] Thu, 18 August 2011 04:08 Go to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
I have:
create or replace function getCapatTransa2 return sys_Refcursor is
   tmp sys_Refcursor;
   error varchar2(1500);
begin
    open tmp for select 'x' from dual;
    return tmp;
end getCapatTransa2;



then
create or replace function get_capat_transa(p1 sys_refcursor, p2 number) return varchar2 is
  cod varchar2(40);
begin
  for i in 1..p2 loop
--    if p1%isopen then
      --raise_application_error (-20667, cod);
      fetch p1 into cod;
  end loop;
  return cod;
end;



and finally:
select get_capat_transa(getCapatTransa2, 1 ) cod 
  from dual



Why in 9i returns invalid cursor and in 11 returns 'x' ? Seems like in 9i the cursor p1 is not open, but why? i can't explain..

[Updated on: Thu, 18 August 2011 04:09]

Report message to a moderator

Re: invalid cursor in 9i (but works on 11g) [message #520026 is a reply to message #520023] Thu, 18 August 2011 04:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Newer versions fix bugs and add features to old ones.

Regards
Michel

[Updated on: Thu, 18 August 2011 04:16]

Report message to a moderator

Re: invalid cursor in 9i (but works on 11g) [message #520027 is a reply to message #520026] Thu, 18 August 2011 04:15 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Ok, so in 9i, what i want to do is not possible in other way?
Re: invalid cursor in 9i (but works on 11g) [message #520029 is a reply to message #520027] Thu, 18 August 2011 04:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You didn't explain us what you want to do.

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520030 is a reply to message #520029] Thu, 18 August 2011 04:21 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
To fetch a ref cursor value into a varchar2 value, because i need the result in a record group (Oracle Forms) and there i need that as varchar.

That's what i want to do with that 'fetch p1 into cod'
Re: invalid cursor in 9i (but works on 11g) [message #520031 is a reply to message #520030] Thu, 18 August 2011 04:25 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why not "var := get_capat_transa(getCapatTransa2, 1 )"?
I don't know Forms, if it is now a Forms question tell us we will move the topic to the appropriate forum.

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520032 is a reply to message #520031] Thu, 18 August 2011 04:32 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
No, because i need the result of get_capat_transa in a select.
Re: invalid cursor in 9i (but works on 11g) [message #520038 is a reply to message #520032] Thu, 18 August 2011 04:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why?

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520041 is a reply to message #520038] Thu, 18 August 2011 04:53 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Besides which, if it works as PL/SQL that'll help narrow the problem down. Just try it.
Re: invalid cursor in 9i (but works on 11g) [message #520042 is a reply to message #520038] Thu, 18 August 2011 04:54 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Don't ask WHY, i need it in that manner and that's all. Is it possible in someway on 9i, or not?
Re: invalid cursor in 9i (but works on 11g) [message #520045 is a reply to message #520042] Thu, 18 August 2011 04:59 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Don't tell us not to ask why.
We need to know why you are trying to do what you are doing so that we can suggest an alternative that'll work.
As it stands it looks like you can't use a ref_cursor in a select in 9i like that.
If you really "need it in that manner and that's all" then you're just going to have to abandon using 9i aren't you?
What a stupid thing to say.

EDIT: typo

[Updated on: Thu, 18 August 2011 05:04]

Report message to a moderator

Re: invalid cursor in 9i (but works on 11g) [message #520056 is a reply to message #520045] Thu, 18 August 2011 06:06 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Our production database is still on Oracle 9i. And i need it in a select, because the Oracle Forms RECORD GROUPS (required to build a LOV - list of values) does not work with ref cursors.
Re: invalid cursor in 9i (but works on 11g) [message #520058 is a reply to message #520056] Thu, 18 August 2011 06:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
So it is a Forms question after all.

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520059 is a reply to message #520058] Thu, 18 August 2011 06:19 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Ok, So:
1) Does the PL/SQL assignment work?
2) Does the SQL version work in sqlplus? - ie is it just forms that's complaining?
Re: invalid cursor in 9i (but works on 11g) [message #520063 is a reply to message #520059] Thu, 18 August 2011 06:38 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
What do you mean by "Does the PL/SQL assignment work?" ? exactly, what?
Re: invalid cursor in 9i (but works on 11g) [message #520065 is a reply to message #520063] Thu, 18 August 2011 06:49 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It means can you do the following in SQL*Plus:
declare var varchar2(10);
begin
 var := get_capat_transa(getCapatTransa2, 1 );
end;
/

Then can you do the SELECT in SQL*Plus?

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520066 is a reply to message #520065] Thu, 18 August 2011 06:50 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
No, i got:

ERROR at line 3:
ORA-06550: line 3, column 26:
PLS-00363: expression 'GETCAPATTRANSA2' cannot be used as an assignment target
ORA-06550: line 3, column 2:
PL/SQL: Statement ignored
Re: invalid cursor in 9i (but works on 11g) [message #520068 is a reply to message #520066] Thu, 18 August 2011 06:58 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Doing what?
COPY AND PASTE your SQL*Plus as we did it.

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520081 is a reply to message #520068] Thu, 18 August 2011 08:44 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Doing the code you have posted:

declare var varchar2(10);
begin
 var := get_capat_transa(getCapatTransa2, 1 );
end;
/


you can try it.. you have all the functions you need in the first post
Re: invalid cursor in 9i (but works on 11g) [message #520085 is a reply to message #520081] Thu, 18 August 2011 09:15 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
And it works:
SQL> declare var varchar2(10);
  2  begin
  3   var := get_capat_transa(getCapatTransa2, 1 );
  4  end;
  5  /

PL/SQL procedure successfully completed.

SQL> 


But then we don't have 9i, that was on 10.2.0.5
However you should not be getting that error message. That error message should only happen if the first parameter in get_capat_transa is either IN OUT or OUT. Which it isn't according to the definitions above.
So either you're hitting a very weird oracle bug or you've done something that you haven't told us about.
Re: invalid cursor in 9i (but works on 11g) [message #520091 is a reply to message #520085] Thu, 18 August 2011 09:42 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Maybe it's an Oracle bug, because exactly the same code works on 11g (also on 10 if you have tested), but on 9 i got the mentioned error..
should i write on metalink about this or..?
Re: invalid cursor in 9i (but works on 11g) [message #520095 is a reply to message #520091] Thu, 18 August 2011 10:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why don't you copy and paste your session as we did it?
Maybe you didn't execute it in SQL*Plus.
Can we trust you?

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520173 is a reply to message #520095] Fri, 19 August 2011 01:39 Go to previous messageGo to next message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
Yes.
However, thanks. Problem solved!

[Updated on: Fri, 19 August 2011 01:44]

Report message to a moderator

Re: invalid cursor in 9i (but works on 11g) [message #520177 is a reply to message #520173] Fri, 19 August 2011 01:44 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How?

Regards
Michel
Re: invalid cursor in 9i (but works on 11g) [message #520268 is a reply to message #520177] Sat, 20 August 2011 01:57 Go to previous message
Roger22
Messages: 98
Registered: April 2009
Location: Brasov, ROMANIA
Member
My bad.. as you said. I did not run that command from Sql*Plus Neutral Sorry..
Now it's ok, thanks for help
Previous Topic: 10g - enter_query/execute_query-problem
Next Topic: How to Change LOV language
Goto Forum:
  


Current Time: Wed Aug 21 14:39:52 CDT 2024