pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Boes <jeff@endpoint.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: psql client: technique for applying default values to :variables?
Date: Mon, 16 Jan 2006 10:33:39 -0500
Message-ID: <43CBBCD3.80506@endpoint.com> (raw)
In-Reply-To: <77ABDE37-069C-4467-BF6D-CC0402218BDB@myrealbox.com>
References: <43C55316.60403@endpoint.com>
	<6d8daee30601111551y68b2663ek6484c830f2107bee@mail.gmail.com>
	<43C910B6.9080904@endpoint.com>
	<77ABDE37-069C-4467-BF6D-CC0402218BDB@myrealbox.com>

Michael Glaesemann wrote:
>
> On Jan 14, 2006, at 23:54 , Jeff Boes wrote:
>
>> Tony Wasson wrote:
>
>>
>> Sure, but that was not my question. I want to be able to set the
>> variable on the command line, BUT have it default to a value inside
>> the SQL script if not present on the command line.
>
> You could write a wrapper script that would accept a command line
> argument and load the file with the appropriate SET statement prepended.

Which really gains me nothing over just:

$ psql -f myscript.sql -v "MYVAR=${myvar:-default}"

The original question was: how can I store the default value in the
"myscript.sql" script where it's used, rather than have it in a calling
script? The aim here was to put the default in the code, so they would
be bound together...


-- 
Jeffery Boes  <><
jeff@endpoint.com




view thread (6+ messages)  latest in thread

Message-ID: <43CBBCD3.80506@endpoint.com>
Permalink:  ../43CBBCD3.80506@endpoint.com/
Also on:    postgresql.org/message-id/43CBBCD3.80506@endpoint.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: jeff@endpoint.com
  Subject: Re: psql client: technique for applying default values to :variables?
  In-Reply-To: <43CBBCD3.80506@endpoint.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