Thread: pl/pgsql function problem
I am having problems doing what seems to be a very simple thing. All I need is to join 2 or more variables (eg char, int, date) and return them as a single varchar variable. eg ret := int + char + date; or better still join("+", int,char,date) return ret; some additional info. I have read in the documentation that you can concat with the || operator. However because one or more of the variables may be empty this seems not to work. If one of the variables is empty nothing is returned. Please can anyone help. Thanks in advance David Mulcahy.
On Sat, 2001-09-08 at 01:09, David Mulcahy wrote: > I am having problems doing what seems to be a very simple thing. All I > need is to join 2 or more variables (eg char, int, date) and return them > as a single varchar variable. > > eg ret := int + char + date; or better still join("+", int,char,date) > return ret; Use COALESCE( VALUE, ...) to replace nulls with default values - it will return the first non-null argument from the list of values. Older versions of PL/PGSQL will always return null if any argument to the function is null, so you may have to use this where you _call_ the function, rather than within the function. Regards, Andrew. -- _____________________________________________________________________ Andrew McMillan, e-mail: Andrew @ catalyst . net . nz Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington Me: +64(21)635-694, Fax:+64(4)499-5596, Office: +64(4)499-2267xtn709
Can someone point me in right direction on how to solve the following error that I'm getting while trying to connect to my database for use in pgaccess.... ======================== [spiritwind@c1347127-a handiman]$ /usr/bin/postmaster -i -D /usr/local/pgsql/handiman2 DEBUG: database system was shut down at 2001-09-10 09:32:46 PDT DEBUG: CheckPoint record at (0, 1522164) DEBUG: Redo record at (0, 1522164); Undo record at (0, 0); Shutdown TRUE DEBUG: NextTransactionId: 615; NextOid: 18720 DEBUG: database system is in production state FATAL 1: Database "handiman2" does not exist in the system catalog. FATAL 1: Database "/usr/local/pgsql/handiman2" does not exist in the system catalog. /usr/bin/postmaster: dumpstatus: