title: How to show output of dbms_output.put_line used in procedure in sqlplus?
body: <p>I am trying to execute the procedure from my plsql block using SQLPLUS, unfortunately, I am not able to see the output from "dbms_output.put_line" from procedure just after the execution of SQL script, though the output is visible in the spool file, I wanted to show output in screen once the execution is completed.</p>
  
  <p>For now, I am getting prompt but No output, though when I perform "SET SERVEROUTPUT ON;" in SQL developer it shows output, what shall I do to see the output in sqlplus once execution is completed.</p>
  
  <p><strong>Output in SQLPLUS</strong></p>
  
  <p><a href="https://i.stack.imgur.com/xQwdG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xQwdG.png" alt="enter image description here"></a></p>
  
  <p><strong>Output in SQL Developer</strong></p>
  
  <p><a href="https://i.stack.imgur.com/9i3pA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9i3pA.png" alt="enter image description here"></a></p>
  
  <p><strong>Table Structure and Data</strong></p>
  
  <pre><code>create table cust_temp_temp
  (name varchar2(20) , id varchar2(20));
  
  insert into cust_temp_temp
  select 'hasu t', '100' from dual
  union all
  select 'hasu r', '100' from dual
  union all
  select 'hasu e', '100' from dual
  union all
  select 'hasu  w', '100' from dual
  union all
  select 'hasu q', '100' from dual;
  </code></pre>
  
  <p><strong>Package Structure :</strong></p>
  
  <pre><code>CREATE OR REPLACE PACKAGE CUSTOM_PKG
  AS
  PROCEDURE get_transaction_details(
        id_ cust_temp_temp.id%TYPE);
  END CUSTOM_PKG;
  /
  </code></pre>
  
  <p><strong>Package Body :</strong></p>
  
  <pre><code>CREATE OR REPLACE PACKAGE BODY CUSTOM_PKG
  AS
  PROCEDURE get_transaction_details
    (
      id_ cust_temp_temp.id%TYPE
    )
  AS
  BEGIN
    dbms_output.put_line('SESSION DETAILS : ');
    FOR CUR_CUSTOM_LOG IN
    (SELECT name,
        id
      FROM cust_temp_temp
      WHERE id = id_
    )
    LOOP
      dbms_output.put_line('Name : '||CUR_CUSTOM_LOG.name);
      dbms_output.put_line('Id : '||CUR_CUSTOM_LOG.id);
    END LOOP;
    dbms_output.put_line('----------------');
  END;
  END CUSTOM_PKG;
  /
  </code></pre>
  
  <p><strong>Script :</strong></p>
  
  <pre><code>SPOOL temp.lst;
  SET TIME ON;
  SET DEFINE OFF;
  SET TERMOUT OFF;
  SET PAGESIZE 20000;
  SET LINESIZE 150;
  SET ECHO ON;
  SET SERVEROUTPUT ON;
    BEGIN
      CUSTOM_PKG.get_transaction_details(10);
    END;
  /
  SET ECHO OFF;
  SET TIME OFF;
  SET LINESIZE 100;
  SET TERMOUT ON;
  SET DEFINE ON;
  SPOOL OFF;
  </code></pre>