Oracle - String empezando por (Starts With)

El script/procedimiento abajo testa si una dada Organización es padre de una segunda pasada como argumento:

declare
dummy varchar2(500);
f_unit varchar2(50);
f_parent_unit varchar2(50);
begin
f_unit := 'AA-ABC';
f_parent_unit := 'AA-AB';
begin
select * into dummy
from dual
where f_unit like f_parent_unit || '%'
and f_unit != f_parent_unit;
dbms_output.put_line('DATA FOUND');
exception
when others then
dbms_output.put_line('NO DATA FOUND');
end;
end;
/


En una forma aun mas general solo necesitéis:

begin
select * into dummy
from dual
where f_unit like f_parent_unit || '%'
and f_unit != f_parent_unit;
dbms_output.put_line('DATA FOUND');
exception
when others then
dbms_output.put_line('NO DATA FOUND');

Comments

Popular posts from this blog

Oracle - duplicate fields in RECORD,TABLE or argument list are not permitted

Oracle - ORA-29282: invalid file ID, ORA-06512: at "SYS.UTL_FILE"