Tony Wasson wrote:
On 1/11/06, Jeff Boes <[EMAIL PROTECTED]> 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; 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. $ psql -v edate=2004-01-01 ... => \set edate 'CURRENT_DATE::DATE' => select :edate; date ------------ 2006-01-14 -- Jeffery Boes <>< [EMAIL PROTECTED] |
- Re: [SQL] psql client: technique for applying default ... Jeff Boes
- Re: [SQL] psql client: technique for applying def... Michael Glaesemann
- Re: [SQL] psql client: technique for applying... Jeff Boes
- Re: [SQL] psql client: technique for appl... Andreas Seltenreich