Thread: a few Questions about quoted variables in psql

a few Questions about quoted variables in psql

From
"Leo Leo"
Date:
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

--
+++ Jetzt WLAN-Router f�r alle DSL-Einsteiger und Wechsler +++
GMX DSL-Powertarife zudem 3 Monate gratis* http://www.gmx.net/dsl


SQLyog for PostgreSQL has been released

From
Karam Chand
Date:
Hello,

As a MySQL and PostgreSQL developer, I had been using
SQLyog for long for my MySQL work. Now they have
released it for PostgreSQL also. Check their post at:

http://www.webyog.com/forums/index.php?s=3d509372b5d4a724c38ab8704da7a708&act=ST&f=2&t=472&st=0&#entry3219

Hope it helps to all the fellow PostgreSQL developers.

Regards,
Karam



__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail