Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Location
    Jagdishpur
    Posts
    146

    Unanswered: Message from Inside Trigger

    Hi,
    I have written a trigger where i am using DBMS_OUTPUT.PUT_LINE('New line text for testing....');. When trigger is being executed, the message written in DBMS_OUTPUT.PUT_LINE is not displayed on the fron-end say SQLPLUS, Whereas raise_application_error(-20999,'string') is fired.

    Is it possible to display message using DBMS_OUTPUT.PUT_LINE. Pls. help. Thanks.

    Regards,
    - KR

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Message from Inside Trigger

    Originally posted by RastogiKamesh
    Hi,
    I have written a trigger where i am using DBMS_OUTPUT.PUT_LINE('New line text for testing....');. When trigger is being executed, the message written in DBMS_OUTPUT.PUT_LINE is not displayed on the fron-end say SQLPLUS, Whereas raise_application_error(-20999,'string') is fired.

    Is it possible to display message using DBMS_OUTPUT.PUT_LINE. Pls. help. Thanks.

    Regards,
    You will get the message in SQL Plus, as long as you issue SET SERVEROUTPUT ON first:

    SQL> create table junk (id number);

    Table created.

    SQL> create or replace trigger junk_trg after insert on junk
    2 for each row
    3 begin
    4 say('you inserted id='||:new.id);
    5* end;
    SQL> /

    Trigger created.

    SQL> insert into junk values(1);

    1 row created.

    SQL> SET SERVEROUTPUT ON
    SQL> insert into junk values(2);
    you inserted id=2

    1 row created.

    However, SQL Plus is the ONLY front end where you will see such messages normally. With other front ends you would have to explicitly call DBMS_OUTPUT.ENABLE and DBMS_OUTPUT.GET_LINES, and then write the message to the screen yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •