declare l_sql varchar2(500); -- variable that contains a query l_c sys_refcursor; -- cursor variable(weak cursor). l_res1 VARCHAR2(60 BYTE); -- variable containing fetching data l_res2 VARCHAR2(60 BYTE); -- variable containing fetching data l_res3 date; -- variable containing fetching data begin l_sql := 'SELECT column_name, table_name FROM USER_TAB_COLUMNS'; open l_c for l_sql; loop fetch l_c into l_res1,l_res2; exit when l_c%notfound; -- Exit the loop if there is nothing to fetch. if l_res1 = 'ACCT_NUM' then dbms_output.put_line(l_res2); end if; -- process fetched data end loop; close l_c; -- close the cursor end; / commit;