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

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Tried that - same result.
Did you connect the DBMS output windows in SQLDeveloper? DBMS output won't appear in the ordinary script output window.
I had to also add set serveroutput on size 30000;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.