Search code examples
oracle-databaseplsqlplsqldeveloper

How To Enable dbms_output in PL/SQL Developer


I know it's a simple thing but I can't seem to find a solution, how do I enable dbms_output in PL/SQL Developer. From googling all I got was how to enable it in sql developer but thats not what I'm looking for... I thought it should be automatically enabled in PL/SQL Developer but for example this block outputs nothing for me.

declare
  v_sample employees.first_name%type;
begin
  select first_name 
  into v_sample
  from employees
  where employee_id = 100;

  dbms_output.put_line(v_sample);
end;

Solution

  • By default, PL/SQL Developer automatically retrieves DBMS_OUTPUT and you don't have to do anything extra to retrieve it. You do not need to use a Command Window to see output. (And you should generally avoid the Command Window - it's a terrible way to program.)

    Go to Configure --> Preferences --> Oracle --> Output, and ensure that the "Enabled" button is checked: enter image description here

    Another possibility is that the FIRST_NAME value is null and there is nothing to output. To avoid that confusion, I typically add a hard-coded value before outputting variables:

    dbms_output.put_line('Name: ' || v_sample);