On 1/13/23 11:13, David G. Johnston wrote:
> On Fri, Jan 13, 2023 at 9:12 AM Ron <ronljohnsonjr(at)gmail(dot)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')
This one looks clean, and works perfectly:
> '%' || :'v_ssn' || '%'
--
Born in Arizona, moved to Babylonia.