pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leo Leo <leoel@gmx.at>
To: pgsql-sql@postgresql.org
Subject: a few Questions about quoted varaibles in psql
Date: Thu, 26 Feb 2004 16:58:28 +0100 (MET)
Message-ID: <9042.1077811108@www35.gmx.net> (raw)

Hi!

How can I interpret a variable in psql, when the variable has to be quoted?

for example:

\set myVar myValue
\echo :myVar
The Result ist then "myValue" ==> ok

But: in my case the variable-values have to be in quotes:

\set db_username myUsername
\set db_password myPassword

CREATE USER :db_username WITH PASSWORD :db_password

==> This will not work, because you need quotes

CREATE USER :db_username WITH PASSWORD ':db_password'

==> This will create the user with Password :db_password and not myPassword
(so it takes the name of the varibale and not den value)

I played a bit with excaping, but even '\'':db_password'\'' will not work

What can I do, in order to achieve, that psql interprets a variable in
quotes?

Another Problem:
================
How can I concatenate a variable with a string without having a space in
between?

\set foo bar
\echo :foo test
==> bar test  (but there is a space in between)

\echo :foo||test
==> this does not work (I want bartest)
Is it somehow possible to do this?

Thanks for your help!

Leo

-- 
GMX ProMail (250 MB Mailbox, 50 FreeSMS, Virenschutz, 2,99 EUR/Monat...)
jetzt 3 Monate GRATIS + 3x DER SPIEGEL +++ http://www.gmx.net/derspiegel +++




Message-ID: <9042.1077811108@www35.gmx.net>
Permalink:  ../9042.1077811108@www35.gmx.net/
Also on:    postgresql.org/message-id/9042.1077811108@www35.gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: leoel@gmx.at
  Subject: Re: a few Questions about quoted varaibles in psql
  In-Reply-To: <9042.1077811108@www35.gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox