drop table tab1 purge;
create table tab1(col1 varchar2(10));
insert into tab1 values('Hello');
insert into tab1 values('World');
commit;
var myVar varchar2(10)
--entered 'll'
exec :myVar := 'll';
select * from tab1 where col1 like '%' || decode(:myVar,'<ALL>',null,:myVar) || '%';
--entered null
exec :myVar := null;
select * from tab1 where col1 like '%' || decode(:myVar,'<ALL>',null,:myVar) || '%';
--entered '<ALL>'
exec :myVar := '<ALL>';
select * from tab1 where col1 like '%' || decode(:myVar,'<ALL>',null,:myVar) || '%';
|