Search Postgresql Archives

Re: Directly embedding a psql SET variable inside another string?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/13/23 11:13, David G. Johnston wrote:
On Fri, Jan 13, 2023 at 9:12 AM Ron <ronljohnsonjr@xxxxxxxxx> wrote:

is there any way to directly embed v_ssn in another string?

No
As expected, this fails:

postgres=# SELECT * FROM employee WHERE ssn LIKE :'%v_ssn%';
ERROR:  syntax error at or near ":"
LINE 1: SELECT * FROM employee WHERE ssn LIKE :'%v_ssn%';


Two options:

format('%%%s%%', :'v_ssn')

This one looks clean, and works perfectly:

'%' || :'v_ssn' || '%'

--
Born in Arizona, moved to Babylonia.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux