SQLPLUS: can substitution variable &1 have a default? [message #399739] |
Thu, 23 April 2009 16:41 |
mgrimley
Messages: 1 Registered: April 2009
|
Junior Member |
|
|
Hello,
Is it possible to have a default value for an &1 substitution variable in an sqlplus script?
When the user executes the script, if they provide a value then I want &1 to use this value. This works fine. But if they run the script without providing a value, then sqlplus prompts for a value as follows
Enter value for 1:
But what I would like to do is to default &1 to a value defined in the script instead of prompting the user. Is there anyway to accomplish this?
Thanks for your help,
Mary
|
|
|
|
|
Re: SQLPLUS: can substitution variable &1 have a default? [message #399784 is a reply to message #399739] |
Fri, 24 April 2009 01:27 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
This doesn't answer your problem exactly, but ... perhaps might help in certain situations: instead of one ampersand (&), try with two of them (&&). Doing so, you'll have to enter value only once; every new query execution won't prompt you for the value:SQL> select count(*) from emp
2 where deptno = &&1;
Enter value for 1: 10
COUNT(*)
----------
3
SQL> /
COUNT(*)
----------
3
SQL> /
COUNT(*)
----------
3
SQL>
|
|
|