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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Directly embedding a psql SET variable inside another string?
Дата
Msg-id CAKFQuwaj1xXH6gA=eqJp7JmwF3GzDwBSRLzqmedycL80EnwGQg@mail.gmail.com
обсуждение исходный текст
Ответ на Directly embedding a psql SET variable inside another string?  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: Directly embedding a psql SET variable inside another string?  (Ron <ronljohnsonjr@gmail.com>)
Список pgsql-general
On Fri, Jan 13, 2023 at 9:12 AM Ron <ronljohnsonjr@gmail.com> 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')
'%' || :'v_ssn' || '%'

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: Adam Scott
Дата:
Сообщение: Re: Directly embedding a psql SET variable inside another string?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Directly embedding a psql SET variable inside another string?