Re: Psql Internal Variable question

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Prafulla Tekawade <prafulla(dot)tekawade(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Psql Internal Variable question
Date: 2011-06-01 07:14:27
Message-ID: BANLkTimkse0t2Kz3JeF94+D_j=LLvk3s4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

\set removes outer quotes

if you use PostgreSQL 9.0 you can use

\set xxx 'Pavel ''Stěhule'

postgres=# \set
AUTOCOMMIT = 'on'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
VERBOSITY = 'default'
VERSION = 'PostgreSQL 9.1beta1 on x86_64-unknown-linux-gnu, compiled
by gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4), 64-bit'
DBNAME = 'postgres'
USER = 'pavel'
PORT = '5432'
ENCODING = 'UTF8'
EDITOR_LINENUMBER_SWITCH = '+'
HISTSIZE = '6000'
HISTFILE = '~/.psql_history-5432'
xxx = 'Pavel 'Stěhule'

postgres=# \echo :'xxx'

'Pavel ''Stěhule'

Regards

Pavel

2011/6/1 Prafulla Tekawade <prafulla(dot)tekawade(at)gmail(dot)com>:
> Hi,
>
> I am trying to use psql \set and \echo commands to set some internal
> variables.
> My variable starts with single quote and ends with single quote.
> That is actual value of the variable.
>
> Eg.
> set cur_db 'pgdb'
> \echo :cur_db
> --I am expecting here 'pgdb' but psql shows pgdb
>
> As mentioned above, I am expecting \echo to return 'pgdb' to me but it
> returns pgdb.
> I tried using escape char, but it did not work.
> Can somebody help me?
>
>
>
> --
> Thanks
> Prafulla
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carl von Clausewitz 2011-06-01 08:08:14 Need suggestion
Previous Message Brendan Jurd 2011-06-01 03:55:26 Re: search_path versus dynamic CREATE SCHEMA