Re: [GENERAL] Using Substitution Variables In PostgreSQL - Mailing list pgsql-general

From Osahon Oduware
Subject Re: [GENERAL] Using Substitution Variables In PostgreSQL
Date
Msg-id CAGpiUSiVis=6CKpHNK9Z+HDAaJ9OU7=H=aNU1YQ8v-3-NV-xpg@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Using Substitution Variables In PostgreSQL  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Thanks for the information.

On Mon, Oct 16, 2017 at 3:27 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Mon, Oct 16, 2017 at 7:08 AM, Osahon Oduware <osahon.gis@gmail.com> wrote:
Hi All,

I wanted to find out how to use a substitution variable in an SQL statement that would cause the user to be prompted for a value. Something similar to the ampersand (&&) in ORACLE.

For example, given the SQL statement below:
    SELECT <col1>,<col2>,<col3>
    FROM <table>
    WHERE <col5> = 35

I want the user to be prompted for the value in the WHERE (filter) clause, e.g.
    SELECT <col1>,<col2>,<col3>
    FROM <table>
    WHERE <col5> = ?

I would be glad if someone could point me in the right direction.

​That would be a client-side feature.  The only client supported on this list is psql.  psql does not have this capability.  It does have the "\prompt" ​meta-command which will serve in this specific case.

\prompt 'Enter a value for varname' varname

SELECT ... WHERE <col5> = :'varname';


David J.


pgsql-general by date:

Previous
From: said assemlal
Date:
Subject: Re: [GENERAL] could not fdatasync log file: Input/output error
Next
From: Seamus Abshere
Date:
Subject: Re: [GENERAL] Non-overlapping updates blocking each other