Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Easy SQL*Plus question (I think)

Re: Easy SQL*Plus question (I think)

From: Jason Judge <jason.judge_at_virgin.net>
Date: Thu, 21 Oct 1999 22:59:46 +0100
Message-ID: <7uo1o8$lf4$1@nclient15-gui.server.virgin.net>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US