473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

REF CURSOR returned from Java -- How to use?

Oracle has a tech article describing how a Java stored procedure
can return a REF CURSOR:

http://www.oracle.com/technology/sam...cur/index.html

Here's the procedure spec:

CREATE OR REPLACE PACKAGE REF_CURSOR_TEST AS

TYPE RC is ref cursor return test_int_trans%rowtype;
FUNCTION TEST return rc;

END REF_CURSOR_TEST;

If I use the SQL/Plus syntax given in the example to access
the returned REF CURSOR, everything works:

SQL>variable x refcursor
SQL>execute :x := getemps;
SQL>print x

This prints all the rows in the cursor. However, I'm stumped on
how to use the resulting cursor from PL/SQL code. Here's what I've
tried:

declare
TYPE RC IS REF CURSOR RETURN TEST_INT_TRANS%rowtype;
C1 RC;
ITEM PRO_INT_TRANS_ITEM;
TRANS TEST_INT_TRANS%rowtype;
begin
c1 := ref_cursor_test.test();
loop
fetch c1 into trans;
exit when c1%notfound;
item := trans.item;
dbms_output.put_line(item.member_id);
end loop;
end;

The error message is:

ORA-06550: line 7, column 10:
PLS-00382: expression is of wrong type

It appears to be complaining about the assignment
to c1. Can anyone point out where I'm going wrong?
Jul 19 '05 #1
1 9539
Jim Garrison wrote:
Oracle has a tech article describing how a Java stored procedure
can return a REF CURSOR:

declare
TYPE RC IS REF CURSOR RETURN TEST_INT_TRANS%rowtype;

Make the cursor type generic, thus:
TYPE RC IS REF CURSOR;
and the problem goes away

I guess the cursor loses its class identity when being
marshalled through the interface and becomes a generic
REF CURSOR, and gets cast back to the correct type
automagically on the fetch.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fereshteh Shojaei | last post by:
Hi, I wonder if somebody could help me. I would like to move the cursor from one JTextField to another one when I press <CR>. Regards, Fereshteh
6
by: Matthew Houseman | last post by:
All, I've created a synonym that points to a package over a database link like so: CREATE SYNONYM API_MYLINK FOR USER.CSAPI_V2@INSTANCE.DOMAIN.COM I've granted execute like so: grant execute...
0
by: Prashanth | last post by:
I am getting this error from BEA DB2 Driver in weblogic console. java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE java.sql.SQLException: CURSOR C02 NOT IN A PREPARED STATE We keep...
4
by: Bernard Dhooghe | last post by:
To retrieve data from a query where multiple rows can be returned, a cursor can be used. Different programming interface exist for cursors: embedded SQL, CLI, SQL PL, SQLJ, JDBC. I we look at...
4
by: _link98 | last post by:
Problem: java ResultSet cursor from SQL/PL stored-procedure is FORWARD_ONLY. Is it possible to have ResultSet cursors from SQL/PL procedures to scroll forward and backwards? Perhaps I am missing...
10
by: technocrat | last post by:
Hi, I am trying to declare and cursor and thn load from that cursor into another table. Since I have almost 4 million records, I cant do it without the cursor which reduces the time by almost...
3
by: IW2FIV | last post by:
I'm a really beginner about sql2000. During my test I have created the following query. It's works ok until I do't add the code included in section A, when I add it the i obtain the error: Cursor...
2
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
1
by: Jim Garrison | last post by:
Oracle has a tech article describing how a Java stored procedure can return a REF CURSOR: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/refcur/index.html Here's the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.