Hi,
Actually i am confused how to write my problem in the above subject part. So, perhaps subject may seems to be confusing or it may be not clear. Ok let me give an example to explain my problem.Here is the code:
DECLARE
TYPE MY_CUR IS REF CURSOR;
CURSOR C IS SELECT * FROM T_GKM_TEST;
MY_ROW T_GKM_TEST%ROWTYPE;
L_CUR MY_CUR;
BEGIN
OPEN L_CUR FOR 'SELECT * FROM T_GKM_TEST';
LOOP
FETCH L_CUR INTO MY_ROW;
EXIT WHEN L_CUR%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(MY_ROW.EMP_ID);
END LOOP;
OPEN L_CUR FOR 'SELECT * FROM T_GKM_TEST';
LOOP
FETCH L_CUR INTO MY_ROW;
EXIT WHEN L_CUR%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(MY_ROW.EMP_NAME);
END LOOP;
END;
In the above code, 'MY_CUR' is a REF CURSOR type variiable. This is like a pointer that can point to any query.
But why i have to reuse 'MY_CUR' in this statement : ' L_CUR MY_CUR; '
Why i have to create another variable ' L_CUR ' which is of type ' MY_CUR ' ?
Why can't i directly use ' MY_CUR ' to refer any sql statement like this :
OPEN MY_CUR FOR 'SELECT * FROM T_GKM_TEST';
The above statement is giving error :
PLS-00330: invalid use of type name or subtype name