calling dbms_output.put_line from a package not printing.

I have two pacjakes dr_lib_package will consist of a number of utilities functions and procedures. I want to be able to call these utilities in another package eg test_package, however when I call pr_echo in test package nothing is printed to the screen, whats going on or what am I doing wrong thanks.

CREATE OR REPLACE package body dr_lib_package
as
      procedure pr_echo (str_switch in varchar2, str_echo in varchar2)

   is

   begin
   
         if str_switch = 'yes' then  
        
         dbms_output.put_line ('printed string ' || str_echo);

         end if;
   
   end pr_echo;
   
end dr_lib_package;

//////////////////////////////////////////////////////////////////////////////
CREATE OR REPLACE package body test_package
as

   procedure test (p_rec_num in binary_integer)
   is
      v_procedure_nm varchar2(100) := 'test_package.test;
      v_print_msg varchar2(100)        := 'yes';
        
 
   begin

             
  dr_lib_package.pr_echo (v_print_msg, v_test||'procedure name =   '||v_procedure_nm||' test num '||p_rec_num);

   end test;


////////////////////////////////// IN TOAD

begin
test_package.insert_rec('4');
end;

I would expect the following to be printed out but nothing is, not sure how to switch server output = on in pl/sql, not sure if that is the problem. Any suggestions why this is not working.

procedure name =   test_package.test test num = 4
dplinnaneAsked:
Who is Participating?
 
MrNedConnect With a Mentor Commented:
you can try dbms_output.enable(100000);
0
 
SMartinHamburgCommented:
>> not sure how to switch server output = on in pl/sql,

You can't switch this on as part of the package!
You will have to include SET SERVEROUTPUT ON in any sql calling procedures from your package
(or otherwise make sure this option ist set).

Regards
0
 
anand_2000vCommented:
in toad type on the screen
set serveroutput on

and then execute your packaged procedure.
You have a tab window below visible which will have your output.
Regards
0
 
kumaran100Commented:
Hi,
IF your are calling and testing from a sql prompt  (sql plus, pl/sql developer, toad etc)
put   the following code
set serveroutput on 10000
The is nothing wrong in that.
Oracle will print ur server output once all the procedures all completed. While executing it won't give u the output.
Some times it wont print anything because it  din't flush the output buffer.
So What u have to do is Simply Type the following  in the sql prompt
begin
dbms_output.put_line('Testing..........');
end;
/

Then u call ur test procedure.
Hope this will work fine.

regards,
kums
0
 
MikeOM_DBACommented:
Use:

DBMS_OUTPUT.ENABLE (1000000);

0
All Courses

From novice to tech pro — start learning today.