Prompt for parameter value in psql

Started by Tiffany Thangabout 8 years ago3 messagesgeneral
Jump to latest
#1Tiffany Thang
tiffanythang@gmail.com

Hi,
Would it be possible to prompt for a user input in psql like in Oracle
sqlplus?

In oracle, we use the & sign, for example,
select * from emp where empid=&empidvalue;

Thanks.

#2Melvin Davidson
melvin6925@gmail.com
In reply to: Tiffany Thang (#1)
Re: Prompt for parameter value in psql

On Fri, Mar 16, 2018 at 11:12 AM, Tiffany Thang <tiffanythang@gmail.com>
wrote:

Hi,
Would it be possible to prompt for a user input in psql like in Oracle
sqlplus?

In oracle, we use the & sign, for example,
select * from emp where empid=&empidvalue;

Thanks.

*https://www.postgresql.org/docs/9.6/static/app-psql.html
<https://www.postgresql.org/docs/9.6/static/app-psql.html&gt; \prompt [ text ]
name *

*Prompts the user to supply text, which is assigned to the variable name.
An optional prompt string, text, can be specified. (For multiword prompts,
surround the text with single quotes.)*

*By default, \prompt uses the terminal for input and output. However, if
the -f command line switch was used, \prompt uses standard input and
standard output.*

--
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Tiffany Thang (#1)
Re: Prompt for parameter value in psql

Hi

2018-03-16 16:12 GMT+01:00 Tiffany Thang <tiffanythang@gmail.com>:

Hi,
Would it be possible to prompt for a user input in psql like in Oracle
sqlplus?

In oracle, we use the & sign, for example,
select * from emp where empid=&empidvalue;

https://www.postgresql.org/docs/current/static/app-psql.html

see \prompt

Regards

Pavel

Show quoted text

Thanks.