Hello everybody,
I'm working on a piece of sql that I want to optimize. I have inside a bunch of cursors. I'm wondering if I can use something else instead of cursors. I'm thinking using some kind of variables, filling them, and for the rest of the treatment avoiding the DB connection (I have a complex treatment).
For instance I have a piece of code like :
TYPE rec_basket IS RECORD (
FIELD1 VARCHAR2(40),
FIELD2 NUMBER(10),
FIELD3 VARCHAR2(6)
);
TYPE tab_basket IS TABLE OF rec_basket
INDEX BY BINARY_INTEGER;
........................
CURSOR cur_baskets
IS
select * from toto
............................
FOR i IN cur_baskets
LOOP
l_tab_basket (l_nbasket).field1 := i.field1;
l_tab_basket (l_nbasket).field2 := i.field2;
l_tab_basket (l_nbasket).field3 := i.field3;
l_nbasket := l_nbasket + 1;
END LOOP;
Using a cursor and filling the l_tab_basket variable is the best way to go? I'm using l_tab_basket (index) somewhere in my code. The reason I've put this piece of code is that I would like use this mechanism for my other cursors. Actually I have a cursor inside another one. And for each line of each of them I have some treatment. I would like to replace the cursors with something else, but I don't know how. Thanks.