I'm studying the differences between bind variables(:) and ampersand operator(& / substitution variables). I realized that "double ampersand is stored variable values and reused these values where it is the same session.".
According to this fact, if I use the double ampersand, then I can avoid hard parsing or not?
Title asks for difference between
&and&&.Both are used with substitution variables (as you already know). Here's a simple and rather dummy example, but will illustrate the difference.
First option: only one
&used with the same substitution variable name; you're required to enter the same value twice (or, as many times as needed):Re-run the same query - you'll again be prompted:
Second option:
&&, which results in only one prompt to enter the value:What happens if I re-run it? The same (old!) value will be used, without any prompt:
If you want to use another substitution variable value, undefine it and then run the query:
As of question you posted in the body (about hard parsing): substitution variables, as far as I can tell, won't help in that. Bind variables would.
Have a look at what BluShadow wrote on OTN Forums (PL/SQL 101 : Substitution vs. Bind Variables):
Also, note that substitution variables can't be used everywhere; it depends on a tool you use. For example, SQL*Plus works with them, TOAD doesn't recognize them, etc.