Две проблемы я вижу в размещенном коде.
create
в коде. Я не уверен, почему у вас есть create
в вашем анонимном блоке.
У вас есть следующий SELECT в вашем блоке DO:
SELECT count(id_contrato) as id_cantidad,
CASE when count(id_contrato) = 0 THEN 'ImagesHappyMaritransparente1.png'
when count(id_contrato) is null THEN 'ImagesHappyMaritransparente1.png'
when count(id_contrato) = 1 THEN 'ImagesTITIhappymarycontratos-off-1_145.png'
when count(id_contrato) = 2 THEN 'ImagesTITIhappymarycontratos-off-2_145.png'
when count(id_contrato) = 3 THEN 'ImagesTITIhappymarycontratos-off-3_145.png'
when count(id_contrato) = 4 THEN 'ImagesTITIhappymarycontratos-off-4_145.png'
when count(id_contrato) = 5 THEN 'ImagesTITIhappymarycontratos-off-5_145.png'
when count(id_contrato) = 6 THEN 'ImagesTITIhappymarycontratos-off-6_145.png'
when count(id_contrato) = 7 THEN 'ImagesTITIhappymarycontratos-off-7_145.png'
when count(id_contrato) = 8 THEN 'ImagesTITIhappymarycontratos-off-8_145.png'
when count(id_contrato) = 9 THEN 'ImagesTITIhappymarycontratos-off-9_145.png'
when count(id_contrato) > 9 THEN 'ImagesTITIhappymarycontratos-off-9+_145.png'
END
FROM BEA.FACT_CONTRATOS
WHERE cantDiasDif > 0 AND Id_rangoContrato IN (id_renovacion, id_renovacionpending);
И вы не сохраняете возвращенный результат SELECT ни в одну переменную. Если вам не нужен результат SELECT, используйте PERFORM, как указано ниже:
PERFORM count(id_contrato) as id_cantidad,
CASE when count(id_contrato) = 0 THEN 'ImagesHappyMaritransparente1.png'
when count(id_contrato) is null THEN 'ImagesHappyMaritransparente1.png'
when count(id_contrato) = 1 THEN 'ImagesTITIhappymarycontratos-off-1_145.png'
when count(id_contrato) = 2 THEN 'ImagesTITIhappymarycontratos-off-2_145.png'
when count(id_contrato) = 3 THEN 'ImagesTITIhappymarycontratos-off-3_145.png'
when count(id_contrato) = 4 THEN 'ImagesTITIhappymarycontratos-off-4_145.png'
when count(id_contrato) = 5 THEN 'ImagesTITIhappymarycontratos-off-5_145.png'
when count(id_contrato) = 6 THEN 'ImagesTITIhappymarycontratos-off-6_145.png'
when count(id_contrato) = 7 THEN 'ImagesTITIhappymarycontratos-off-7_145.png'
when count(id_contrato) = 8 THEN 'ImagesTITIhappymarycontratos-off-8_145.png'
when count(id_contrato) = 9 THEN 'ImagesTITIhappymarycontratos-off-9_145.png'
when count(id_contrato) > 9 THEN 'ImagesTITIhappymarycontratos-off-9+_145.png'
END
FROM BEA.FACT_CONTRATOS
WHERE cantDiasDif > 0 AND Id_rangoContrato IN (id_renovacion, id_renovacionpending);
Однако, вопрос, почему вы хотите это сделать? Сообщите нам причину отказа от сохранения результатов SELECT или вашего намерения.