Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a variable in pl/sql

Status
Not open for further replies.

maswien

Technical User
Sep 24, 2003
1,286
CA

What is the command to display a variable in PL/SQL?
 
I don't know really what you mean. If you mean for debugging purposes to output a line to standard output with the variable's contents, you can use

dbms_output.putln(variable)

You'll need to set serveroutput on in sqlplus before exec'ing the pl/sql, though.

Mark [openup]
 


I put this line to the SP, but I got error:

PLS-00302: component 'PUTLN' must be declared
 
Could you (1) post your code and (2) explain what it is you are trying to do (when you say "display a variable", what is it you would like to do/see?)?

 
Hi,
Make use of DBMS_OUTPUT.PUT_LINE.

E.g.
Code:
SQL> set serveroutput on
SQL> declare
  2   a number(10);
  3   cursor c1 is 
  4    select empno from emp;
  5  begin
  6    for i in c1 loop
  7      a:=i.empno;
  8      dbms_output.put_line('Value of a is = '||a);
  9    end loop;
 10  end;
 11  /
Value of a is = 1
Value of a is = 10
Value of a is = 20
Value of a is = 5555
Value of a is = 7521
Value of a is = 7566
Value of a is = 7654
Value of a is = 7698
Value of a is = 7782
Value of a is = 7788
Value of a is = 7839
Value of a is = 7844
Value of a is = 7876
Value of a is = 7899
Value of a is = 7900
Value of a is = 7902
Value of a is = 7934

PL/SQL procedure successfully completed.

HTH
Regards
Himanshu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top