Re: BUG #4944: Problems with using \set variables as strings in select statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bruno Scovoli Santos" <bruno(dot)scovoli(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4944: Problems with using \set variables as strings in select statements
Date: 2009-07-27 14:36:15
Message-ID: 10370.1248705375@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Bruno Scovoli Santos" <bruno(dot)scovoli(at)gmail(dot)com> writes:
> brunodb=# \set nom 'Intel'
> euclidhardware=# select * from fabricantes where nome like :nom;
> ERROR: column "intel" does not exist
> LINE 1: select * from fabricantes where nome like Intel;

If you want to put quotes in the value of a variable, you need
this
\set nom '''Intel'''
or this
\set nom '\'Intel\''
the same as you would to write a string literal containing quotes
in SQL.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message dan boeriu 2009-07-27 21:56:57 BUG #4945: Parallel update(s) gone wild
Previous Message Rolf Jentsch 2009-07-27 14:31:19 Re: BUG #4944: Problems with using \set variables as strings in select statements