Thread: trapping a NULL querystring error

trapping a NULL querystring error

From
Gerardo Herzig
Date:
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

From
"A. Kretschmer"
Date:
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