dbTalk Databases Forums  

Cursor Ref Issue: What am I missing?

comp.databases.oracle.server comp.databases.oracle.server


Discuss Cursor Ref Issue: What am I missing? in the comp.databases.oracle.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KevinS
 
Posts: n/a

Default Cursor Ref Issue: What am I missing? - 09-30-2010 , 08:56 AM






Hi all,

The coded below sets up and hopefully demonstrates an issue I am
having.

The line 'OPEN v_my_cur;' in tha package body produces the error
'Expresssion is of wrong type.

The database is Oracle Database 10g Enterprise Edition Release
10.2.0.3.0 - 64bit.

Any ideas what's I've missed?

thanks


CREATE TABLE my_table(a VARCHAR2(1),b VARCHAR2(1));

INSERT INTO my_table(a,b) VALUES('a','b');

CREATE OR REPLACE PACKAGE MY_REF_CURSOR_PKG AS

PROCEDURE MY_prc;

END MY_REF_CURSOR_PKG;

CREATE OR REPLACE PACKAGE BODY MY_REF_CURSOR_PKG
AS

TYPE my_rec IS RECORD(
a my_table.b%TYPE,
b my_table.b%TYPE);
TYPE my_cur IS REF CURSOR RETURN my_rec;

Function get_data_fnc
RETURN my_cur
IS
my_rc my_cur;
BEGIN

OPEN my_rc
FOR
SELECT t.a, t.b
FROM my_table t;

RETURN my_rc;

END get_data_fnc;

PROCEDURE my_fnc
IS

v_my_cur my_cur;

BEGIN

v_my_cur := get_data_fnc;

OPEN v_my_cur;

LOOP
FETCH v_my_cur INTO r_failed_wo;
EXIT WHEN v_my_cur%NOTFOUND;
END LOOP;

END my_fnc;

END MY_REF_CURSOR_PKG;

Reply With Quote
  #2  
Old   
Thomas Olszewicki
 
Posts: n/a

Default Re: Cursor Ref Issue: What am I missing? - 09-30-2010 , 09:26 AM






On Sep 30, 9:56*am, KevinS <sear... (AT) googlemail (DOT) com> wrote:
Quote:
Hi all,

The coded below sets up and hopefully demonstrates an issue I am
having.

The line 'OPEN v_my_cur;' in tha package body produces the error
'Expresssion is of wrong type.

The database is Oracle Database 10g Enterprise Edition Release
10.2.0.3.0 - 64bit.

Any ideas what's I've missed?

thanks

CREATE TABLE my_table(a VARCHAR2(1),b VARCHAR2(1));

INSERT INTO my_table(a,b) VALUES('a','b');

CREATE OR REPLACE PACKAGE MY_REF_CURSOR_PKG AS

* PROCEDURE MY_prc;

END MY_REF_CURSOR_PKG;

CREATE OR REPLACE PACKAGE BODY MY_REF_CURSOR_PKG
AS

* TYPE my_rec IS RECORD(
* * * *a * * * * my_table.b%TYPE,
* * * *b * * * * my_table.b%TYPE);
* TYPE my_cur IS REF CURSOR RETURN my_rec;

* Function get_data_fnc
* RETURN my_cur
* IS
* * my_rc my_cur;
* BEGIN

* * OPEN my_rc
* * FOR
* * SELECT t.a, t.b
* * FROM my_table t;

* * RETURN my_rc;

* END get_data_fnc;

* PROCEDURE my_fnc
* IS

* * v_my_cur *my_cur;

* BEGIN

* * v_my_cur := get_data_fnc;

* * OPEN v_my_cur;

* * LOOP
* * FETCH v_my_cur INTO r_failed_wo;
* * EXIT WHEN v_my_cur%NOTFOUND;
* * END LOOP;

* END my_fnc;

END MY_REF_CURSOR_PKG;

OPEN v_my_cur;
Isn't v_my_cur already open inside function get_data_fnc?
Thomas

Reply With Quote
  #3  
Old   
KevinS
 
Posts: n/a

Default Re: Cursor Ref Issue: What am I missing? - 09-30-2010 , 10:05 AM



This is indeed the case, something I had not grasped before, so I
therefore don't need the line 'OPEN v_my_cur;'.

Having said that how is this a type mismatch..... but that's another
story.

For the moment problem solved.

Thank you for you help.

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.