1

I'm trying to learn PL/SQL by simply assigning a variable from a select statement and then, to confirm it's working, print it sql output.

DECLARE ALLOW_STUFF NUMBER;
BEGIN
   SELECT VAL_N INTO ALLOW_STUFF FROM MY_TABLE WHERE MY_KEY = 'ALLOW_ME';
   DBMS_OUTPUT.PUT_LINE(ALLOW_STUFF);
END;

I'm using SQL Developer and/or SQL PLus. When I run this, all I get is

Anonymous block completed

Rather than than the value of MY_TABLE.VAL_N

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Lurk21
  • 2,307
  • 12
  • 37
  • 55
  • 1
    `set serveroutput on` http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_eight.htm#sthref952 –  Mar 05 '14 at 17:59

1 Answers1

3

You need to enable output, otherwise the DBMS_OUTPUT.PUT_LINE statements are ignored. Output can be enabled using:

DBMS_OUTPUT.ENABLE();

For more information about DBMS_OUTPUT read Oracle documentation: http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_output.htm#i1000634

As stated in the comments also set serveroutput on can be used.

Aivis
  • 106
  • 3