Re: [GENERAL] How can I interpolate psql variables in function bodies? - workaround

2009-06-24 Thread J. Greg Davidson
I've found a workaround using the new pg 8.3 feature of default values for function arguments. It is not a completely general workaround (it won't, e.g. allow type or table names to be interpolated) but it does what I need and perhaps others may find this trick useful. To briefly recap the

Re: [GENERAL] How can I interpolate psql variables in function bodies?

2009-06-24 Thread J. Greg Davidson
On Tue, 2009-06-16 at 09:20 +0200, Albe Laurenz wrote: I came up with the following: psql -v foo=10 test= \set funcbody `echo 'SELECT\ `:foo`echo '` test= create function foo() returns integer as :funcbody language sql; But that is ugly as hell and depends on the underlying operating

Re: [GENERAL] How can I interpolate psql variables in function bodies?

2009-06-16 Thread Albe Laurenz
J. Greg Davidson wrote: Hi dear colleagues, I'm trying to pull some platform-specific constants out of my code by using psql variables, e.g.: $ psql -v TypeLength=4 # CREATE TYPE tref ( INTERNALLENGTH = :TRefTypeLength, INPUT = tref_in, OUTPUT = tref_out, PASSEDBYVALUE );

[GENERAL] How can I interpolate psql variables in function bodies?

2009-06-15 Thread J. Greg Davidson
Hi dear colleagues, I'm trying to pull some platform-specific constants out of my code by using psql variables, e.g.: $ psql -v TypeLength=4 # CREATE TYPE tref ( INTERNALLENGTH = :TRefTypeLength, INPUT = tref_in, OUTPUT = tref_out, PASSEDBYVALUE ); which works fine, but when I need