亲爱的朋友们,我将这些陈述存储在一个表格中,我需要执行它们才能收到结果。
DECODE (to_char((SELECT s1.streettypename FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||''|| to_char((SELECT s0.streetname FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||''|| to_char(NRO_VIA) ||''|| to_char(NRO_PUERTA),'', 'No Disponible', to_char((SELECT s1.streettypename FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||' '|| to_char((SELECT s0.streetname FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||' '|| to_char(NRO_VIA) ||' '|| to_char(NRO_PUERTA))',DECODE (to_char((SELECT s1.streettypename FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||''|| to_char((SELECT s0.streetname FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||''|| to_char(NRO_VIA) ||''|| to_char(NRO_PUERTA),'', 'No Disponible', to_char((SELECT s1.streettypename FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||' '|| to_char((SELECT s0.streetname FROM autodesk.smstreets s0, autodesk.smstreettypes s1 where s0.streettypeid = s1.streettypeid(+) AND s0.streetantiq=0 AND s0.streetid=COD_VIA)) ||' '|| to_char(NRO_VIA) ||' '|| to_char(NRO_PUERTA)) FROM cliente WHERE NRO_CLIENTE='104631'
DECODE (observaciones, NULL, 'No Disponible', '', 'No Disponible', observaciones)',DECODE (observaciones, NULL, 'No Disponible', '', 'No Disponible', observaciones) FROM cliente WHERE NRO_CLIENTE='104631'
to_char((SELECT areaname FROM autodesk.amareas a0 WHERE a0.areaid=COD_DISTRITO))',to_char((SELECT areaname FROM autodesk.amareas a0 WHERE a0.areaid=COD_DISTRITO)) FROM cliente WHERE NRO_CLIENTE='104631'
to_char((SELECT areaname FROM autodesk.amareas a0 WHERE a0.areaid=COD_PROVINCIA))',to_char((SELECT areaname FROM autodesk.amareas a0 WHERE a0.areaid=COD_PROVINCIA)) FROM cliente WHERE NRO_CLIENTE='104631'
to_char(correlativo)',to_char(correlativo) FROM cliente WHERE NRO_CLIENTE='104631'
sed',sed FROM cliente WHERE NRO_CLIENTE='104631'
to_char(telefono)',to_char(telefono) FROM s_v_cliente WHERE NRO_CLIENTE='104631'
to_char(numero_medidor)',to_char(numero_medidor) FROM tps.s_v_medid, cliente c WHERE NRO_CLIENTE='104631'
to_char(d.Consumo)',to_char(d.Consumo) FROM cliente c,(SELECT Id_Cuenta, Consumo FROM (SELECT a.Id_Cuenta, b.ENERGIA_FP Consumo FROM s_NUC_SERVICIO a, s_his_consumo b WHERE UPPER(a.tipo_Servicio) = 'ELECTRICO' AND a.id_servicio=b.id_servicio AND a.Id_Cuenta= %ID_ELEMENTO% ORDER BY fecha_lectura DESC) WHERE ROWNUM <=1) d WHERE NRO_CLIENTE='104631'
to_char(d.Potencia)',to_char(d.Potencia) FROM cliente c,(SELECT Id_Cuenta, Potencia FROM (SELECT a.Id_Cuenta, (SELECT potencia_cont_fp FROM s_v_cliente WHERE numero_cliente = a.Id_Cuenta) Potencia FROM s_NUC_SERVICIO a, s_his_consumo b WHERE UPPER(a.tipo_Servicio) = 'ELECTRICO' AND a.id_servicio = b.id_servicio AND a.Id_Cuenta = %ID_ELEMENTO% ORDER BY fecha_lectura DESC) WHERE ROWNUM <=1) d WHERE NRO_CLIENTE='104631'
fase',fase FROM cliente WHERE NRO_CLIENTE='104631'
to_char(NRO_CLIENTE)',to_char(NRO_CLIENTE) FROM cliente WHERE NRO_CLIENTE='104631'
nombre',nombre FROM cliente WHERE NRO_CLIENTE='104631'
to_char(pcr)',to_char(pcr) FROM cliente WHERE NRO_CLIENTE='104631'
TO_CHAR(DECODE(TIPO,1,'NORMAL',2,'MAXIMETRO',4,'PIMT',7,'HH.UU. Y PP.JJ',8,'ALUMBRADO PUBLICO','No Disponible'))',TO_CHAR(DECODE(TIPO,1,'NORMAL',2,'MAXIMETRO',4,'PIMT',7,'HH.UU. Y PP.JJ',8,'ALUMBRADO PUBLICO','No Disponible')) FROM cliente WHERE NRO_CLIENTE='104631'
TO_CHAR(DECODE(estado,0,'ACTIVO',1,'ELIMINADO',2,'RETIRADO',3,'NUEVO',4,'PROCESO DE RETIRO','No Disponible'))',TO_CHAR(DECODE(estado,0,'ACTIVO',1,'ELIMINADO',2,'RETIRADO',3,'NUEVO',4,'PROCESO DE RETIRO','No Disponible')) FROM cliente WHERE NRO_CLIENTE='104631'
cadena',cadena FROM cliente WHERE NRO_CLIENTE='104631'
to_char(sector)',to_char(sector) FROM cliente WHERE NRO_CLIENTE='104631'
to_char(zona)',to_char(zona) FROM cliente WHERE NRO_CLIENTE='104631'
答案 0 :(得分:0)
如果看起来像这些都是返回1行2列的select语句(在开始时减去关键字select
,并且语法错误很多)那么你可以这样做:
declare
l_sql long;
l_col1 long;
l_col2 long;
begin
for r_sql in (select statement from my_table) loop
dbms_output.put_line('Statement: '||r_sql.statement);
l_sql := 'select '||r_sql.statement;
begin
execute immediate l_sql into l_col1, l_col2;
dbms_output.put_line('returned: '||l_col1||','||l_col2);
exception
when no_data_found then
-- take appropriate action
when too_many_rows then ...
-- take appropriate action
end;
end loop;
end;
但这仅在数据中的语法错误得到修复时才有效 - 例如
to_char(NRO_CLIENTE)',to_char(NRO_CLIENTE) FROM cliente WHERE NRO_CLIENTE='104631'
...在to_char(NRO_CLIENTE)
之后有一个虚假的'会导致语句在运行时失败。