Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Easy SQL*Plus question (I think)
Yes - when you want to be prompted for a substitution variable use an
ampersand:
&var1
If you want to reuse this value in another instance of this variable then use a double ampersand:
&&var1
The second example will not prompt, but will reuse the value already prompted for.
An alternative is to assign the prompted value to a variable then use the variable, so in PL/SQL you may have:
DECLARE
var1 VARCHAR2(60) := '&var1';
BEGIN
dbms_output.put_line('Value is ' || var1);
END;
You can also set these variables up without having to prompt:
SET var1 = 'a value'
(check the SQL*Plus manual for the format on this one). I find this very useful when writing scripts that contain many parts (e.g. DDL, DML, SQL blocks in one or more files) and can set global variables such as user names, database names and passwords once at the top then reference them in many places as &&variable.
Regards,
Jason Judge
jason.judge_at_iee.org.co.uk
Received on Thu Oct 21 1999 - 16:59:46 CDT
![]() |
![]() |