|
-
I don't think you can use a cursor in a cursor.
With a REF CURSOR and 2 loops it is possible:
DECLARE
TYPE cur_typ IS REF CURSOR;
c cur_typ;
query_str VARCHAR2(1000);
CURSOR GetColsCurs IS
SELECT col_name, empno
FROM emp_cols;
rval VARCHAR2(1000);
rempno NUMBER;
...
BEGIN
FOR GetColsCursRec IN GetColsCurs
LOOP
query_str := 'SELECT '||GetColsCursRec.col_name||
', empno FROM emp WHERE '||
GetColsCursRec.col_name||' !=0 AND '||
GetColsCursRec.col_name||' IS NOT NULL';
OPEN c FOR query_str
LOOP
FETCH c INTO rval, rempno;
EXIT WHEN c%NOTFOUND;
INSERT INTO dwh_table
VALUES(GetColsCursRec.col_name, rval, rempno);
END LOOP;
END LOOP;
END;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|