Re: psql questions - Mailing list pgsql-novice

From Walker, Jed S
Subject Re: psql questions
Date
Msg-id 41669DC6FE3B80449A33A4DD46DB370A09E7E8B1@entcoexch15.broadband.att.com
Whole thread Raw
In response to psql questions  ("Walker, Jed S" <Jed_Walker@cable.comcast.com>)
Responses Re: psql questions
List pgsql-novice
Hi John,

Thanks, I had tried the semi-colon, it's the unusual quoting syntax I was
missing.

\set '/'jed\''
select :jed;

Is that the only way you can quote it to make a string work?



-----Original Message-----
From: John DeSoi [mailto:desoi@pgedit.com]
Sent: Thursday, March 24, 2005 5:07 PM
To: Walker, Jed S
Cc: 'pgsql-novice@postgresql.org'
Subject: Re: [NOVICE] psql questions



On Mar 24, 2005, at 6:29 PM, Walker, Jed S wrote:

> How can do those things in psql?  (I found the \set which seems to
> work, no
> error, but I can't figure out how to use the variable in a psql
> session)


You prefix the variable with a colon to get the value. Here are a few
examples:

\set mystring '\'here is a string\''

select :mystring || ' test';
        ?column?
----------------------
  here is a string test
(1 row)


\set myint 37

select :myint + 10;
  ?column?
----------
        47
(1 row)


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: stored procedures?
Next
From: "Walker, Jed S"
Date:
Subject: outputting everything from psql to a file