Stephen Lasky
Stephen Lasky

Reputation: 447

Oracle SQL*Plus: Use Substitution Variables Twice

How do I enter a substitution variable such that it can be used multiple times throughout a SQL statement?

For example

SELECT '&X','&X',A       <--SEES X AS TWO DIFFERENT VARIABLES
FROM T; 

Sees each X as a different variable. How can I make it such that X is only one variable?

Upvotes: 2

Views: 1261

Answers (1)

Gary_W
Gary_W

Reputation: 10360

If you mean you are prompted twice for a value for the same variable, use 2 ampersands instead of one for a permanent substitution variable instead of a temporary substitution variable. Here's an explanation of the difference: What is the difference between & and &&?

Upvotes: 5

Related Questions