Bulk assembling a subset of columns from Oracle Cursor

A stored procedure is given that cannot be changed. It returns a cursor with the number of columns in the result. Is there an easy way in Oracle for BULK COLLECT INTOonly a subset of the columns provided by the cursor?

FORloops and new collection types should be avoided. I would not want to extract all the data from the cursor, namely the data that is needed.

For example, BULK COLLECTION INTOall columns from the cursor will work:

FETCH s_cursor BULK COLLECT INTO staff_ids;
+3
source share
2 answers

"", , , , , , .

+2

.

PL/SQL :

type c_col1 is table of s_cursor.col1%type index by pls_integer;
type c_col2 is table of s_cursor.col2%type index by pls_integer;
type c_col3 is table of s_cursor.col3%type index by pls_integer;
t_col1 c_col1;
t_col2 c_col2;
t_col3 c_col3;

:

fetch s_cursor bulk collect into t_col1, t_col2, t_col3;

:

t_col2.delete;
t_col3.delete;

, , .

+1

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


All Articles