Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: NEWBIE: Trying to run an anonymous block (PL/SQL)
On Tue, 18 Nov 2003 22:57:39 +0100, "Carlos Jose Guerrieri"
<carlos.guerrieri_at_realize-it.com> wrote:
>i`m new to PL/SQL. I bought the ORACLE PL/SQL book from Feuerstein
The third edition? If you look in whatever chapter it is that talks about CLOBs, you'll find a somewhat gratuitious photo of a frozen waterfall not too far from where I live in Munising.
I can help with the SQL*Plus part of your question. See below.
>try to run some examples but i have my problems to get it run.
>I tried the following anonymous block in TOAD and i get no output. Maybe
>someone can figure out what i did wrong?
>
>DECLARE
> today DATE DEFAULT SYSDATE;
>BEGIN
> DBMS_OUTPUT.PUT_LINE ('Today is ' || today);
>END;
>
>I tried this also in SQL*PLUS but had no success too. It expect more input
>(line) after the end-statement.
In SQL*Plus you'll want to do two things. First, execute the following command to tell SQL*Plus to actually display the output:
SET SERVEROUTPUT ON Then, end your PL/SQL block with a forward-slash on the first character of a line by itself. For example:
DECLARE
today DATE DEFAULT SYSDATE;
BEGIN
DBMS_OUTPUT.PUT_LINE ('Today is ' || today);
END;
/
SQL*Plus can't count on the semicolon to end a block, because semicolons are used within blocks. Thus, the choice was made years ago to have a forward-slash tell SQL*Plus that you are done entering the block.
Use a period rather than a slash to stop entering a block when you just want to leave it in the buffer without executing it. Then, later, you can type a / to execute the block. You can execute the same block repeatedly by typing / followed by Enter over and over.
Jonathan Gennick --- Brighten the corner where you are http://Gennick.com
Join the Oracle-article list and receive one article on Oracle technologies per month by email. To join, visit http://four.pairlist.net/mailman/listinfo/oracle-article, or send email to Oracle-article-request_at_gennick.com and include the word "subscribe" in either the subject or body. Received on Tue Nov 18 2003 - 21:35:41 CST