Best way to use Cursors PL / SQL packages from Pro * C

I have a pointer defined in PL / SQL and I am wondering what is the best way to use it from ProC. Usually for a cursor defined in ProC, you should:

EXEC SQL DECLARE curs CURSOR FOR SELECT 1 FROM DUAL;
EXEC SQL OPEN curs;
EXEC SQL FETCH curs INTO :foo;
EXEC SQL CLOSE cusr;

I was hoping the same (or similar) syntax would work for a packed cursor. For example, I have a MyPack package with an ad

type MyType is record (X integer);
cursor MyCurs(x in integer) return MyType;

Now in my Pro * C code I have a rather unsatisfactory part of the embedded PL / SQL that opens the cursor, makes a selection, etc., since I could not get the first syntax style to work. Using an example

EXEC SQL EXECUTE
  DECLARE
    XTable is table of MyPack.MyType;
  BEGIN
    OPEN MyPack.MyCurs(:param);
    FETCH MyPack.MyCurs INTO XTable;
    CLOSE MyPack.MyCurs;
  END;
END-EXEC;

Does anyone know if there is a cleaner approach for Pro * C?

+3
source share
2 answers

, , , . "" - :

:

create or replace package mypkg as 
  cursor mycur is 
    SELECT 1 FROM DUAL; 
end;

pro * c:

EXEC SQL OPEN schema.mypkg.mycur; 
EXEC SQL FETCH schema.mypkg.mycur INTO :foo; 
EXEC SQL CLOSE schema.mypkg.mycur; 

, , , .. , , "". pro * c.

+1

. Google REF CURSOR, , .

0

Source: https://habr.com/ru/post/1749595/


All Articles