Select dentro del Decode
Estoy intentando realizar la siguiente sentencia y ke devuelve como error PLS-00103: Encountered the symbol "SELECT", no estoy muy especializado en oracle y no se si es posible realizar un select dentro de un decode. ¿alguna ayuda?
DECODE (NEGOCIO,'VEN',OLIQUI.FECCREACION,'COM',DECODE
(OLIQUI.TIPPRECIO,'AF',OLIQUI.FECHAPIZARRA,'HE',(SELECT FECTIPCAMBIO FROM SAGRO.CONTRATO WHERE CONTINTERNO=OLIQUI.CONTINTERNO)))
Muchas gracias,
Ramiro
DECODE (NEGOCIO,'VEN',OLIQUI.FECCREACION,'COM',DECODE
(OLIQUI.TIPPRECIO,'AF',OLIQUI.FECHAPIZARRA,'HE',(SELECT FECTIPCAMBIO FROM SAGRO.CONTRATO WHERE CONTINTERNO=OLIQUI.CONTINTERNO)))
Muchas gracias,
Ramiro
Creo (casi seguro) que no se pueden poner select dentro del decode. Lo que puedes hacer es una función en la que le pases como parámetro los valores del where y te devuelva el resultado de la select. Es decir, algo como:
create or replace function prueba(contint tipo) return tipo as
salida tipo;
begin
SELECT FECTIPCAMBIO into salida
FROM SAGRO.CONTRATO
WHERE CONTINTERNO=contint;
return salida;
end;
y en el decode, en lugar de la select pones:
prueba(OLIQUI.CONTINTERNO)
Espero que te sirva.
create or replace function prueba(contint tipo) return tipo as
salida tipo;
begin
SELECT FECTIPCAMBIO into salida
FROM SAGRO.CONTRATO
WHERE CONTINTERNO=contint;
return salida;
end;
y en el decode, en lugar de la select pones:
prueba(OLIQUI.CONTINTERNO)
Espero que te sirva.
