1

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?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164

1 Answers1

3

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.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384