Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ACCEPT in SQL*Plus
Originally posted by Francesco Sblendorio
> >> variable abc number;
> >> accept abc;
> >> begin
> >> dbms_output.put_line( :abc );
> >> end;
> >> /
>
> Thanks for your help.
> I tried the script you posted: it's executed without errors, but
> it doesn't
> print nothing out, although I already launched "set serveroutput on".
>
> What's the difference between a "variable" and a "host variable"?
>
The code above is incorrect, because the ACCEPT command gets a value
into a substitution variable called &abc, which has no connection with a
variable called abc. It would have to be:
accept abc
begin
dbms_output.put_line(&abc);
end;
/
Substitution variables are processed by SQL Plus, e.g. if &abc is set to 123 then above code is processed as:
begin
dbms_output.put_line(123);
end;
The value 123 is a literal as far as PL/SQL is concerned.
Variables created with the VARIABLE command are true variables, which can be referenced within PL/SQL like :abc. The value can be changed within PL/SQL, e.g.
variable abc number
begin
:abc := 123;
dbms_output.put_line(:abc);
end;
/
-- Posted via http://dbforums.comReceived on Tue Apr 08 2003 - 09:52:47 CDT
![]() |
![]() |