Re: BUG #4944: Problems with using \set variables as strings in select statements - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4944: Problems with using \set variables as strings in select statements
Date
Msg-id 10370.1248705375@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4944: Problems with using \set variables as strings in select statements  ("Bruno Scovoli Santos" <bruno.scovoli@gmail.com>)
List pgsql-bugs
"Bruno Scovoli Santos" <bruno.scovoli@gmail.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

pgsql-bugs by date:

Previous
From: "Bruno Scovoli Santos"
Date:
Subject: BUG #4944: Problems with using \set variables as strings in select statements
Next
From: "fous"
Date:
Subject: BUG #4943: getting error while vacuuming the database