Обсуждение: trapping a NULL querystring error

Поиск
Список
Период
Сортировка

trapping a NULL querystring error

От
Gerardo Herzig
Дата:
Hi all. Inside a plpgsql function, i have a EXECUTE statement, which
sometimes seems to be receiving a null querystring.

Can i check that condition in a BEGIN..EXCEPTION block? Under which
condition?

Or should just check if that string is null?

Thanks!

Gerardo


Re: trapping a NULL querystring error

От
"A. Kretschmer"
Дата:
am  Fri, dem 14.11.2008, um  7:29:32 -0300 mailte Gerardo Herzig folgendes:
> Hi all. Inside a plpgsql function, i have a EXECUTE statement, which
> sometimes seems to be receiving a null querystring.
> 
> Can i check that condition in a BEGIN..EXCEPTION block? Under which
> condition?
> 
> Or should just check if that string is null?

I think, you should prevent NULL-strings. To ensure that you can use
coalesce. For instance:

sql:='SELECT FROM foo WHERE col = ' || coalesce(var, default-value)

Other way: you check if your sql-string is NULL or not


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net