From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Adam Scott <adam.c.scott@gmail.com>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Directly embedding a psql SET variable inside another string?
Date: Fri, 13 Jan 2023 09:13:59 -0800
Message-ID: <d0c8b8a8-0231-1c7c-24d2-c4907e3b1eb3@aklaver.com> (raw)
In-Reply-To: <CA+s62-OBC_VQihE5RMW6_rYyoiH_HCbb6pbPS=+1DwaYOd8Adw@mail.gmail.com>
References: <e556cfc8-30e6-014c-264a-f0b62d71a368@gmail.com>
<CA+s62-OBC_VQihE5RMW6_rYyoiH_HCbb6pbPS=+1DwaYOd8Adw@mail.gmail.com>
On 1/13/23 09:08, Adam Scott wrote:
> Do you mean like this?
>
> postgres=# \set v_embed %:v_ssn%
> postgres=# \echo :v_embed
> %345%
> postgres=# SELECT * FROM employee WHERE ssn LIKE :'v_embed';
> ssn | name
> -----------+----------
> 123456789 | John Doe
> (1 row)
>
>
Actually that replicates what Ron got to work. What Ron is looking for
is to skip the intermediate step and do:
\set v_ssn 345
SELECT * FROM employee WHERE ssn LIKE :'%v_ssn%';
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, adam.c.scott@gmail.com, ronljohnsonjr@gmail.com
Subject: Re: Directly embedding a psql SET variable inside another string?
In-Reply-To: <d0c8b8a8-0231-1c7c-24d2-c4907e3b1eb3@aklaver.com>
References: <e556cfc8-30e6-014c-264a-f0b62d71a368@gmail.com> <CA+s62-OBC_VQihE5RMW6_rYyoiH_HCbb6pbPS=+1DwaYOd8Adw@mail.gmail.com> <d0c8b8a8-0231-1c7c-24d2-c4907e3b1eb3@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox