I need to create a pl/pgsql function witch accept a list of parameters and
evaluate them.
I've tried this
CREATE OR REPLACE FUNCTION get_first_valid (lista_elementi VARCHAR[])
RETURNS VARCHAR AS $$
DECLARE
the_one VARCHAR;
BEGIN
IF (ARRAY_UPPER(lista_elementi, 1) IS NOT NULL) THEN
FOR i IN 1..ARRAY_UPPER(lista_elementi, 1) LOOP
the_one := lista_elementi[i];
IF ((the_one IS NOT NULL) AND (TRIM(the_one) != '') ) THEN
EXIT;
END IF;
END LOOP;
ELSE
the_one := NULL;
END IF;
RETURN (the_one);
END;
$$ LANGUAGE 'plpgsql' VOLATILE;
I know that postgresql array implementation is not right complete and that if
just
one element of array is NULL the basics array function (array_dims,
array_upper, etc.) returns NULL.
I need to send a list of parameters (which could contain NULL values) and
evaluate the parameters excluding NULL values
is this possible?
any suggestion?
Sgarbossa Domenico
Extacy Project Leader
Le informazioni contenute nella presente email e nei relativi allegati
possono essere riservate e sono comunque destinate solo ed esclusivamente alle
persone o all'ente sopra indicati come destinatari. La diffusione,
distribuzione e/o copiatura del documento trasmesso da parte di qualsiasi
soggetto diverso dal destinatario รจ proibita sia ai sensi dell'art. 616 c.p. e
sia ai sensi del dlg 196/03. Se avete ricevuto questo messaggio per errore vi
invitiamo a distruggerlo e ad informarci (+39 049 9318300, [email protected]). The
information in this email, any files transmitted with it included, is
confidential and may also be legally privileged. It is intended for the
addressee only. Access to this email by anyone else is unauthorised. It is not
to be relied upon by any person other than the addressee except with our prior
written approval. If no such approval is given, we will not accept any
liability (in negligence or otherwise) arising from any third party acting or
refraining from acting on such information. Unauthorised recipients are
required to maintain confidentially. If you have received this email in error,
please notify us immediately (+39 049 9318300, [email protected]), destroy any
copies and delete it from your computer system. Any use, dissemination,
forwarding, printing or copying of this email is prohibited.