0

I am an Oracle DB guy and learning Postgres. Want to check if Postgres provides substitution variable functionality to supply value at run time, below is an example from oracle

select * from test where id = '&id'; => & character
Enter value for id: 1

        ID
----------
         1
Pat
  • 59
  • 1
  • 5
  • 1
    Does this answer your question? [How do you use script variables in psql?](https://stackoverflow.com/questions/36959/how-do-you-use-script-variables-in-psql) – Sayan Malakshinov Aug 03 '21 at 01:44
  • 1
    https://stackoverflow.com/questions/36959/how-do-you-use-script-variables-in-psql – Sayan Malakshinov Aug 03 '21 at 01:45
  • **Substitution** variables are entities of SQLPlus and processed only by *tools* that understand them. Their purpose is to replace any text in script, so you may substitute any part of the statement even in the middle of the word. But to substitute the data (as you actually do) you need to use [**bind** variables](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqpug/using-scripts-in-SQL-Plus.html#GUID-B52D6F2E-A28A-48B6-B73F-6A9D018BD107), which are allowed only in places where expression is allowed. They are processed inside DBMS. For this case the above link is valid solution – astentx Aug 03 '21 at 09:28
  • @astentx What I am asking is different than bind variables. This is for substituting any value, could be any of part of statement and not specifically predicate. – Pat Aug 03 '21 at 23:26
  • @Pat Your example was about predicate, this is not how they are supposed to be used. So this may be confusing. – astentx Aug 04 '21 at 07:03
  • Sorry about confusion. Thanks for your response! – Pat Aug 11 '21 at 23:45

0 Answers0