set lines 200
set pages 30000
--SET TRIMOUT OFF
--SET TRIMS OFF
SET COLSEP '|'
SET VER OFF

begin
dbms_output.put_line('----------------------------------------------------------------------');
dbms_output.put_line('ID-IDSERVICIO');
dbms_output.put_line('A-ACTIVE');
dbms_output.put_line('S-%SERVICIO%');
dbms_output.put_line('T-%TEGNOLOGIA%');
dbms_output.put_line('C-%CATEGORIA%');
dbms_output.put_line('----------------------------------------------------------------------');
end;
/

--column ID format 999 word_wrapped
column SERVICIO format a20 word_wrapped
column TEGNOLOGIA format a4 word_wrapped
column CATEGORIA format a10 HEADING CATEGORIA word_wrapped

SET TERM OFF
DEFINE V_1 = ''
COLUMN VV_1 NOPRINT NEW_VALUE V_1
SELECT '&&1' VV_1 FROM dual;

DEFINE V_2 = ''
COLUMN VV_2 NOPRINT NEW_VALUE V_2
SELECT '&&2' VV_2 FROM dual;
SET TERM ON

SELECT IDSERVICIO, ACTIVO, SERVICIO, TEGNOLOGIA, CATEGORIA
FROM ASTSYSADMIN.T_MODS_SERVICIOS
where (UPPER('&V_1') = 'ALL') 
OR (UPPER('&V_1') = 'ID' AND IDSERVICIO = '&V_2')
OR (UPPER('&V_1') = 'A' AND ACTIVO = UPPER('&V_2'))
OR (UPPER('&V_1') = 'S' AND SERVICIO LIKE UPPER('%&V_2%'))
OR (UPPER('&V_1') = 'T' AND TEGNOLOGIA LIKE UPPER('%&V_2%'))
OR (UPPER('&V_1') = 'C' AND CATEGORIA LIKE UPPER('%&V_2%'))
--OR (UPPER('&V_1') = 'T' AND TEGNOLOGIA LIKE UPPER('%&V_2%'))
--OR (UPPER('&V_1') = 'P' AND PROGRAMA LIKE UPPER('%&V_2%'))
ORDER BY ACTIVO,TEGNOLOGIA,SERVICIO,CATEGORIA;

UNDEFINE V_1
UNDEFINE V_2


