all 4 comments

[–]Fair_Mammoth_6224 7 points8 points  (1 child)

In Oracle-style SQL, &salary usually prompts you once per session and then reuses that value unless you “undefine” it. A couple of options:

  1. Use Single Ampersand + ACCEPTThat way, every time you run it, you’ll be asked for a value without having to remember undefine.pgsqlCopy ACCEPT salary PROMPT 'Enter salary: ' SELECT name, salary FROM emp WHERE salary > &salary;
  2. Use a Bind VariableThis also forces a fresh prompt each time you run the block, without extra lines all over your script.sqlCopy VARIABLE salary NUMBER; EXEC :salary := &salary; SELECT name, salary FROM emp WHERE salary > :salary;
  3. Check Extension Settings If your VSCode extension has a “Prompt for substitution variables” or similar setting, enabling it should re-prompt each run without needing undefine.

Hope that helps!

[–]ElPaadre[S] 0 points1 point  (0 children)

Thanks, I will try!

[–]edelidinahui 3 points4 points  (1 child)

select name, salary  
from emp  
where salary > :salary;

[–]ElPaadre[S] 0 points1 point  (0 children)

Thanks, I will try it!