Re: psql client: technique for applying default values to :variables?
В списке pgsql-sql по дате отправления:
| От | Andreas Seltenreich |
|---|---|
| Тема | Re: psql client: technique for applying default values to :variables? |
| Дата | |
| Msg-id | 87psmsumvy.fsf@gate450.dyndns.org обсуждение исходный текст |
| Ответ на | Re: psql client: technique for applying default values to :variables? (Jeff Boes <jeff@endpoint.com>) |
| Список | pgsql-sql |
Jeff Boes writes:
> Michael Glaesemann wrote:
>> 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...
How about using the traditional Unix macro processor "m4" instead of
psql's variables?
E.g., you could write a myscript.sql.m4 file with m4 variables instead
of psql ones. You could then use ifdef() to test for previous
definitions, or even define a default()-wrapper macro.
regards,
Andreas
--
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера