问题
I have a plsql that returns a single row and I am executing it by dynamic action, I want to show different error messages by means of APEX_ERROR.ADD_ERROR in case there is no value. Apparently, all the code is correct, but in case of error, it does not show any message.
note: the dynamic action is by pressing a key Condition on the client side javascript = // Enter key this.browserEvent.which === 13 do not submit page.
I do not know if the approach is wrong and you can achieve a better way.
declare
l_serie number;
l_codigo number;
l_product_name varchar2(500);
l_precio number;
l_exists number;
begin
select count(*)
into l_exists
from (
select a.ID_INGRESO_SERIE,
a.CODIGO_PRODUCTO,
(select PRODUCT_NAME
from TBL_PRD_DET
where PRODUCT_ID =a.CODIGO_PRODUCTO ) PRODUCTO,
(select PRICE
from TBL_SALE_PRICE
where PRODUCT_ID=a.CODIGO_PRODUCTO
and INVETORY_TYPE=1) PRECIO
from TBL_INGRESOS_DET_SERIES a
where ID_INGRESO_SERIE =:P58_CODIGO
and ESTADO_SERIE = 1
);
if l_exists > 0 then
select a.ID_INGRESO_SERIE,
a.CODIGO_PRODUCTO,
(select PRODUCT_NAME
from TBL_PRD_DET
where PRODUCT_ID =a.CODIGO_PRODUCTO ) PRODUCTO,
(select PRICE
from TBL_SALE_PRICE
where PRODUCT_ID=a.CODIGO_PRODUCTO
and INVETORY_TYPE=1) PRECIO
into l_serie,l_codigo,l_product_name,l_precio
from TBL_INGRESOS_DET_SERIES a
where ID_INGRESO_SERIE =:P58_CODIGO
and ESTADO_SERIE = 1;
APEX_COLLECTION.ADD_MEMBER (
p_collection_name =>'LISTA_VENTA',
p_n001 =>l_codigo,--CODIGO
p_n002 => 1, ---UNIDADES
p_n003 =>l_precio , ---PRECIO
p_n004 =>0, ---DESCUENTO
p_n005 =>l_serie,---CODIGO SERIE
p_c001 =>l_product_name,---NOMBRE PRODUCTO
p_d001 => SYSDATE
);
else
apex_error.add_error (
p_message => '¡no exit producto!',
p_display_location => apex_error.c_inline_in_notification);
end if;
end;
回答1:
apex_error package is only relevant to page processing, not interactions with dynamic actions.
You'll need to display message using technique like this https://www.talkapex.com/2018/03/custom-apex-notification-messages/
Perhaps using concepts mentioned here https://community.oracle.com/message/14948411#14948411
Where your process would set a hidden value, then be displayed using the custom API. How re-usable you make this is up to you.
来源:https://stackoverflow.com/questions/52613246/how-to-display-a-plsql-error-message-with-dynamic-action