[ACCEPTED]-Ref cursor with Execute immediate-execute-immediate

Accepted answer
Score: 12

Just:

OPEN p_result_set for v_sql using p_name;  

0

Score: 1
  1. You need to create a type to keep the data 4 you select is going to return,for example. Imagine 3 this is yours users table user(id number, name varchar2), your type should 2 look like:

    create type users_type as object (id number, name varchar2);
    
  2. Create a type table to keep object 1 to created above.

    create type users_table_object as table of users_type;
    
  3. create the procedure:

    create the procedure test(
    cv_1  OUT SYS_REFCURSOR
    ....
    )
    as
    users_table_object;
    v_query VARCHAR2(2000);  
    
    begin
    v_query := N'select users_type(id, name) from users ';
    
    execute immediate
    bulk collect into users_table_object;
    
    open cv_1 for table(users_table_object)     
    

More Related questions