欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PL/SQL查询条件中使用like操作实例

程序员文章站 2022-06-16 14:24:21
set serveroutput on declare type ref_trans is ref cursor; tranref ref_trans; v_trns emp%rowtype; st...

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;