From: | "Sgarbossa Domenico" <domenico(dot)sgarbossa(at)eniac(dot)it> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | How to send multiple parameters to a pl/pgsql function |
Date: | 2009-10-21 08:34:01 |
Message-ID: | 808685A13E374430935FEE779B40F6AC@laneniac.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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, info(at)eniac(dot)it). 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, info(at)eniac(dot)it), destroy any copies and delete it from your computer system. Any use, dissemination, forwarding, printing or copying of this email is prohibited.
From | Date | Subject | |
---|---|---|---|
Next Message | Csaba Nagy | 2009-10-21 08:52:42 | Re: PostgreSQL driver for Joomla review |
Previous Message | Ivano Luberti | 2009-10-21 08:23:18 | Re: multi-company design/structure ? |