PL / SQL Parameter Explicit Cursor & For Loop Example

in pl-sql •  7 years ago  (edited)

Using explicit cursor with parameters and usable For Loop together is very convenient. Explicit cursors with parsers are reusable and for loops are simple to reuse. For example,

DECLARE
IS
CURSOR SAMPLE_CUR (V_SAMPLE IN VARCHAR2)
IS SELECT C1
, C2
, C3
, C4
FROM SAMPLE_TABLE
WHERE KEY = V_SAMPLE ;
BEGIN

FOR SAMPLE_REC IN SAMPLE_CUR ('1234')
LOOP
DBMS_OUTPUT.PUT_LINE(SAMPLE_REC.C1);
......
END LOOP;

END;

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!