From: | chrisj <chrisj(dot)wood(at)sympatico(dot)ca> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | is there a way to determine the attributes of anyelement |
Date: | 2007-04-12 01:29:50 |
Message-ID: | 9951488.post@talk.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have written a simple procedure that accepts anyarray, and concatinates the
elements separated by a space and returns the result to anyelement.
I know when I call this function I will always be passing varchars. If the
length of the resultant concatination
is longer than the maximum length of the return varchar I want to truncate
at the max. Since I don't know the max length of the return varchar I now
get an error in this situation:
ERROR: value too long for type character varying(10)
is there a way to determine the maximum length of the varchar of anyelement
inside the function?
Here is my simple function:
create or replace function concat_arr( p_array anyarray
) returns anyelement as \$\$
DECLARE
out_char ALIAS FOR \$0;
BEGIN
out_char := '' ;
FOR i IN 1..array_upper(p_array, 1) LOOP
if i <> 1 then
out_char := out_char || ' ' || p_array[i] ;
else
out_char := out_char || p_array[i] ;
end if ;
END LOOP;
return (out_char) ;
END;
\$\$ LANGUAGE plpgsql
;
--
View this message in context: http://www.nabble.com/is-there-a-way-to-determine-the-attributes-of-anyelement-tf3562903.html#a9951488
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | marcelo Cortez | 2007-04-12 01:35:21 | Re: 8.2.3 AutoVacuum not running |
Previous Message | Robert Treat | 2007-04-12 00:28:34 | Re: What about SkyTools? |