[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

return  dbms_output.put_line ('etc'); from function fails error = PLS-00222: no function with name 'PUT_LINE' exists in this scope

Posted on 2004-11-19
7
Medium Priority
?
2,495 Views
Last Modified: 2008-01-09
When I compile in Toad it fails I get the same error if I pass value to str_value but no errors if I use something like retur upper('str_echo').
I basically want to have a print statement through out my code that I can switch on and off for debugging. Any suggestions? Thanks Patrick.

CREATE OR REPLACE package body dr_lib_package
as
   function fx_echo (str_switch in varchar2, str_echo in varchar2)
      return varchar2
   is
      str_value   varchar2 (2000) := null;

   begin
   
   if str_switch = 'yes' then  
       return  dbms_output.put_line ('printed string ' || str_echo);
      --str_value := dbms_output.put_line ('printed string ' || str_echo);
      --return str_value;
   else
      return null;
   end if;
   
   end fx_echo;
end dr_lib_package;
0
Comment
Question by:dplinnane
  • 4
  • 3
7 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12627821
dbms_output.put_line is only used to dump output to the screen (console).

change:
 return  dbms_output.put_line ('printed string ' || str_echo);

to

 return  'printed string ' || str_echo;
0
 
LVL 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 1500 total points
ID: 12627854
I get it now........  sorry.

I haven't tested this but the idea should work (unless I'm still missing the point....which can easily happen):

 if str_switch = 'yes' then  
       dbms_output.put_line ('printed string ' || str_echo);
       return  'printed string ' || str_echo;
   else
      return null;
   end if;
0
 

Author Comment

by:dplinnane
ID: 12627935
You just have to make the function is returing something, so return null works no need to use return  'printed string ' || str_echo;
Thanks this will do.

if str_switch = 'yes' then  
       dbms_output.put_line ('printed string ' || str_echo);
       return null;
   else
      return null;
   end if;
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12628105
Better yet:

if str_switch = 'yes' then  
       dbms_output.put_line ('printed string ' || str_echo);
end if;
return null;
0
 

Author Comment

by:dplinnane
ID: 12628283
Better agin maybe using a procedure because I do not need value passed to a variable, I posted another quest just a few mins ago about adding a line number to print statement so I know which print statement is being printed to screen, if you have any suggestions check it out. Q  = is there a LINE variable in Oracle, need...

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;
0
 

Author Comment

by:dplinnane
ID: 12628949
Problem when I run dr_lib_package.pr_echo ('on', v_test||'procedure name =   '||v_procedure_nm); in another package I get nothing returned to the screen. Not sure why oracle doen't have a simple echo or print variable? Any ideas why nothing is printed out?
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12629358
I've never attempted what you are attempting so I have no specific asnwer.

That said, make sure serveroutput is on and has an adequate size (This gets turned off by default)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question