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;

4

1 回答 1

5

DBMS_Output 是一个 PL/SQL 包,因此您可以从 PL/SQL 代码中调用它。

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;
/
于 2013-05-10T13:31:21.673 回答