Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339893 - Core support for strongly-typed package REF CURSORs
Summary: Core support for strongly-typed package REF CURSORs
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: James Sutherland CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 339721
  Show dependency tree
 
Reported: 2011-03-14 10:21 EDT by Mike Norman CLA
Modified: 2022-06-09 10:14 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Norman CLA 2011-03-14 10:21:48 EDT
An example of a strongly-typed package REF CURSOR:

CREATE OR REPLACE PACKAGE PKG_STRONG_REFCURSOR IS

    TYPE PRICE_RECORD IS RECORD (
        INDEX_RATE NUMBER(6,5),
        INDEX_TYPE VARCHAR2(1)
    );
    TYPE STRONG_REFCURSOR IS REF CURSOR RETURN PRICE_RECORD;

    PROCEDURE FOO(P_RETURN OUT STRONG_REFCURSOR);

END PKG_STRONG_REFCURSOR;

When building the anonymous PL/SQL block, a new nested function is
required to convert the PRICE_RECORD PL/SQL records to a compatible
JDBC Object type:

CREATE OR REPLACE TYPE t_price_rec AS OBJECT (
  INDEX_RATE NUMBER(6,5),
  INDEX_TYPE VARCHAR2(1)
);
CREATE OR REPLACE TYPE t_price_rec_tab AS TABLE OF t_price_rec;


FUNCTION pl2el5(C IN STRONG_REFCURSOR) RETURN t_price_rec_tab
 PIPELINED IS
   TYPE l_cur_type IS REF CURSOR;
   l_cur l_cur_type;
   l_price_rec price_record;
 BEGIN
   OPEN l_cur FOR C;
   LOOP
     FETCH l_cur
     INTO l_price_rec;
     EXIT WHEN l_cur%NOTFOUND;
     PIPE ROW(t_price_rec(
         index_rate => l_rec.index_rate,
         index_type => l_rec.index_type));
 END LOOP;
 RETURN;
END;

Or something like it - more research is required
Comment 1 James Sutherland CLA 2011-04-05 10:13:38 EDT
This seems to work with our existing cursor support.
Strong typed cursors are the same as weak in jdbc, they return rows.
Comment 2 James Sutherland CLA 2011-04-13 09:52:41 EDT
Added test that works with existing support.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:07:15 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:14:03 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink