Re: psql client: technique for applying default values to :variables?
От | Jeff Boes |
---|---|
Тема | Re: psql client: technique for applying default values to :variables? |
Дата | |
Msg-id | 43CBBCD3.80506@endpoint.com обсуждение исходный текст |
Ответ на | Re: psql client: technique for applying default values to :variables? (Michael Glaesemann <grzm@myrealbox.com>) |
Ответы |
Re: psql client: technique for applying default values to :variables?
|
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: