pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tony Wasson <ajwasson@gmail.com>
To: Jeff Boes <jeff@endpoint.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: psql client: technique for applying default values to :variables?
Date: Wed, 11 Jan 2006 16:51:00 -0700
Message-ID: <6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com> (raw)
In-Reply-To: <43C55316.60403@endpoint.com>
References: <43C55316.60403@endpoint.com>

On 1/11/06, Jeff Boes <jeff@endpoint.com> wrote:
> Stumped: is there any way to set up default values for psql variables
> within the .SQL file itself? Obviously, I can do something like:
>
> $ psql -f my_script -v MYVAR=${myvar:-mydefault}
>
> but I would prefer to have the value stored with the .SQL file, e.g. (if
> this actually worked):
>
> \set MYVAR COALESCE(:MYVAR,'mydefault')

Stuff like this works for me in a SQL file....

\set edate 'CURRENT_DATE::DATE'

SELECT * FROM some_table WHERE update_date = :edate;



view thread (6+ messages)  latest in thread

Message-ID: <6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com>
Permalink:  ../6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com/
Also on:    postgresql.org/message-id/6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com

 · 

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: ajwasson@gmail.com, jeff@endpoint.com
  Subject: Re: psql client: technique for applying default values to :variables?
  In-Reply-To: <6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com>

* 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