I am currently trying to populate a cursor in the procedure.
like that :
Function notImportantFunction
variable nothing(20);
Cursor notImportantCursor Is select...;
Cursor THEcursor;
begin
open notImportantCursor;
open THEcursor;
LOOP
FETCH notImportantCursor variable;
EXIT WHEN notImportantCursor%NOTFOUND;
THEcursor is select ...; //trying to populate THEcursor
end loop;
close THEcursor;
close notImportantCursor;
end;
i’ve used weird name for my variable just to show the only important one here is THEcursor.
is what i’m trying even possible? or, how would I be able to do the same in another way.
thank you in advance
I think what you are asking for is “Can I create a cursor based on a query that I don’t have to define when I declare the cursor”
If thats what you want, then look here for information about dynamic sql.
Dynamic SQL
There is a perfect example in the section Referencing Database Objects that Do Not Exist at Compilation.
You can recreate the cursor each time, however you want.
If you need something a little more flexible, like creating a cursor that holds three values in each record and you want to populate those values in different ways, you could look for pipelined table functions