Nulls

Поиск
Список
Период
Сортировка
От Michael Davis
Тема Nulls
Дата
Msg-id 93C04F1F5173D211A27900105AA8FCFC14525C@lambic.prevuenet.com
обсуждение исходный текст
Список pgsql-hackers
I have a function:
void *nz(void *bp) {      text *new_text;      new_text = (text *) palloc(sizeof(text)+2);      memset((void *)
new_text,0, sizeof(text)+2);         strcpy(VARDATA(new_text), ":");      VARSIZE(new_text) = sizeof(text)+2;
return(void *)(new_text);}
 

I define the function in psql:

CREATE FUNCTION nz(text) RETURNS text AS
'/usr/src/pgsql/contrib/spi/psql_ext.so' LANGUAGE 'c';

I call the function:
select addressid, nz(state) from addresses where addressid = 3870;

If state is NULL, nz(state) still returns NULL!  How can I get my nz()
function to reflect something other than NULL?  The purpose behind this is
to have a concatenated string return a value even if any value is null.  For
example:

select addressid, nz(state) || nz(country) from addresses where addressid =
3870;

Returns NULL if state is null or if country is null.  I want it to return
the country if state is null.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "D'Arcy" "J.M." Cain
Дата:
Сообщение: Re: [HACKERS] Niladic functions
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: map