ORACLE copies the result set package to an array

 During the daily development of Oracle, we will encounter some strange requirements. This time we encountered a method that requires assigning the result set to an array and then using the array for subsequent operations. The details are as follows:

DECLARE
  TYPE NUM_ARR IS VARRAY(15) OF NUMBER(15);
  JOBIDS NUM_ARR;
BEGIN
  SELECT JOB_ID BULK COLLECT INTO JOBIDS FROM JOB_HEAD WHERE CREATE_DATE >= SYSDATE - 20;
  DBMS_OUTPUT.put_line(JOBIDS(14));
END;

First declare an array, then use the keyword bult collect into to encapsulate it, and finally call it.

Among them, bulk collect can load the query results into collections at one time and then call them. By the way, using this method to encapsulate the results into a result set at once, the performance will be much better than the cursor. For details, please refer to previous examples . 1 , example 2

The output is as shown below:

Guess you like

Origin blog.csdn.net/qq_42740899/article/details/103669421