Search code examples
variablesscriptingoracle-sqldevelopersqlplussqlreportingservice

How to suppress printing variable name while printing its value in sqlplus?


I am trying to achieve this.

This is my code

var cvar varchar2(20) 
exec :cvar := 'variable value'
print cvar 

This is the current output

PL/SQL procedure successfully completed.


CVAR
--------------------------------------------------------------------------------
variable value

I want to output only the variable value. Not its name or any other output

variable value

I tried all these settings. no luck

SET DEFINE on
SET HEADING OFF
SET VERIFY OFF
SET FEEDBACK ON
SET ECHO OFF
SET PAGESIZE 0
SET TRIMS ON
SET PAGES       1000
SET APPINFO     OFF
SET TIME        OFF
SET TIMING      OFF
SET TERMOUT     ON
SET TRIMS       ON

Solution

  • It is set heading off:

    SQL> var cvar varchar2(20)
    SQL> exec :cvar := 'variable value'
    
    PL/SQL procedure successfully completed.
    
    SQL> print cvar
    
    CVAR
    --------------------------------
    variable value
    

    SQL> set heading off
    SQL> print cvar
                                       --> see? No heading here
    variable value
    
    SQL>