Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group