Tuesday, September 26, 2017

RefCursor

DECLARE
  refvar    VARCHAR2(100)   :='and EMP_MI=''J''';
  query_str VARCHAR2 (3000) := NULL;
TYPE cur_typ
IS
  REF
  CURSOR;
    c cur_typ;
    V_SPRIDEN_ID VARCHAR2(1000);
  BEGIN
    query_str:='SELECT SPRIDEN_ID FROM EMP WHERE EMP_ID in(''G19320418'',''G18649335'')'||refvar||'';
    OPEN c FOR query_str;
    LOOP
      FETCH c INTO V_SPRIDEN_ID;
    EXIT
  WHEN c%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(V_SPRIDEN_ID);
  END LOOP;
  CLOSE c;
END;




No comments:

Post a Comment