2

Problem

I just want to see the value of a variable. I don't understand why this has to be so difficult.

My SQL Statement

--set serveroutput on format wrapped; Tried this too
SET SERVEROUTPUT ON;
--DBMS_OUTPUT.ENABLE(32000); Tried with, and without this

vend_num xx.VENDOR_CWT.VEND_NO%TYPE;
SELECT vend_no 
INTO vend_num 
FROM xx.VENDOR_NAME 
WHERE VENDOR_NAME1 = 'xxxx';

dbms_output.put_line(vend_num);

The Error I'm Geting

Error starting at line 13 in command:
dbms_output.put_line(vend_num)
Error report:
Unknown Command

What I've Tried

I've tried the following answers:

Print text in Oracle SQL Developer SQL Worksheet window

Printing the value of a variable in SQL Developer

I've done what this answer suggested with the gui: https://stackoverflow.com/a/7889380/496680

I've tried exec dbms_output[...] as some posts have suggested.

Question

How do I just print the value of vend_num;

Community
  • 1
  • 1
Steve's a D
  • 3,801
  • 10
  • 39
  • 60

1 Answers1

5

DBMS_Output is a PL/SQL package, so you'd call it from within PL/SQL code.

declare
  end_num xx.VENDOR_CWT.VEND_NO%TYPE;
begin
  SELECT vend_no
  INTO   vend_num
  FROM   xx.VENDOR_NAME
  WHERE  VENDOR_NAME1 = 'xxxx';
  dbms_output.put_line(vend_num);
end;
/
David Aldridge
  • 51,479
  • 8
  • 68
  • 96