set serveroutput on
declare
type ref_trans is ref cursor;
tranref ref_trans;
v_trns emp%rowtype;
str varchar2(200);
–v_channel varchar2(50);
letter char:= ‘a’;
begin
loop
str := ‘select channel from bphadmin.emp where channel like ”’||letter||’%”’;
open tranref for str;
loop
fetch tranref into v_trns.channel;
exit when tranref%notfound;
dbms_output.put_line(v_trns.channel);
end loop;
exit when letter=’z’;
letter:= chr(ascii(letter)+1);
end loop;
end;