Showing Trigger DBMS_OUTPUT.PUT_LINE in Oracle Apex

不打扰是莪最后的温柔 提交于 2021-02-19 08:57:05

问题


I have a trigger:

CREATE OR REPLACE TRIGGER Med_Allergy_Warning BEFORE INSERT ON Prescription FOR EACH ROW
BEGIN
    IF (Find_ADR(:NEW.Visit_ID, :NEW.Medication_ID) != 'GOOOO') THEN
        DBMS_OUTPUT.PUT_LINE('Medication ('||:NEW.Medication_ID||') May cause an allergic reaction… You are warned!');
    ELSE
        DBMS_OUTPUT.PUT_LINE('Medication ('||:NEW.Medication_ID||') was prescribed successfully!');
END IF;
END;/

That outputs a DBMS_OUTPUT.PUT_LINE whenever a user enters a prescription that may cause allergic reactions. However, the user creates the entry in APEX - is there anyway to create a region to show this DBMS_OUTPUT.PUT_LINE message on the same page?


回答1:


In theory, you should be able to call DBMS_OUTPUT.GET_LINE to get the data in your APEX code and display that. However, building application functionality that depends on writing to DBMS_OUTPUT is a terrible approach. If you want to log information about potential allergic reactions, you really, really ought to log that to a table that your APEX application can then report on. Hoping that whatever application issues the INSERT has enabled DBMS_OUTPUT let alone allocated a large enough buffer for the output let alone happened to remember to read from the buffer and display that to a human is a really bad idea.



来源:https://stackoverflow.com/questions/15803779/showing-trigger-dbms-output-put-line-in-oracle-apex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!