| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
|---|---|
| To: | Adam Scott <adam(dot)c(dot)scott(at)gmail(dot)com>, Ron <ronljohnsonjr(at)gmail(dot)com> |
| Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Directly embedding a psql SET variable inside another string? |
| Date: | 2023-01-13 17:13:59 |
| Message-ID: | d0c8b8a8-0231-1c7c-24d2-c4907e3b1eb3@aklaver.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2023-01-13 17:14:45 | Re: Directly embedding a psql SET variable inside another string? |
| Previous Message | David G. Johnston | 2023-01-13 17:13:36 | Re: Directly embedding a psql SET variable inside another string? |