From: | miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Multidimensional array definition in composite type appears parsed as string |
Date: | 2009-05-27 21:13:22 |
Message-ID: | 23750913.post@talk.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane-2 wrote:
>
> It sounds like you are using some code that mistakenly thinks that
> double quotes have a semantic meaning here. They do not. They are just
> there to delimit members of the row value, not to tell you what type the
> members are.
>
Note: quoted text abridged per mailing list rules.
I appreciate the clarification on the output. Given the assignment appears
correct, what is the appropriate method to access the elements of the
multidimensional array? I had mistakenly assumed the following would be
correct:
CREATE TYPE myschema.mytype AS (
sometext text,
onedimarray text[],
multidimarray text[][]
);
CREATE OR REPLACE FUNCTION myschema.mytestfunction() RETURNS void AS $BODY$
DECLARE
myvar myschema.mytype[] := ARRAY[
ROW('textaa',ARRAY['textab'],ARRAY[ARRAY['textac1','textac2']])::myschema.mytype,
ROW('textba',ARRAY['textbb'],ARRAY[ARRAY['textbc1','textbc2']])::myschema.mytype
];
BEGIN
-- Nested loop example to output each element in multidimensional array
for each composite type
FOR i IN array_lower(myvar,1)..array_upper(myvar,1) LOOP
FOR j IN
array_lower((myvar[i]).multidimarray,1)..array_upper((myvar[i]).multidimarray,1)
LOOP
FOR k IN
array_lower((myvar[i]).multidimarray[j],1)..array_upper((myvar[i]).multidimarray[j],1)
LOOP
RAISE INFO '%',(myvar[i]).multidimarray[j][k];
END LOOP;
END LOOP;
END LOOP;
END
$BODY$ LANGUAGE 'plpgsql';
When I attempt the above, it appears (myvar[i]).multidimarray[j] is text
instead of an array of text. Currently, (myvar[i]).multidimarray[j][k]
yields NULL in each case and (myvar[i]).multidimarray[j] yields
"{{textac1,textac2}}" and "{{textbc1,textbc2}}".
Is there an alternate/ preferred method used to access the elements?
Nearly forgot: running Postgres v8.3 on Fedora 10.
Thanks again.
--
View this message in context: http://www.nabble.com/Multidimensional-array-definition-in-composite-type-appears-parsed-as-string-tp23749072p23750913.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Smith | 2009-05-27 21:54:15 | Re: Favorite/Recommended ERD tools |
Previous Message | Scott Bailey | 2009-05-27 20:55:23 | Re: composite type and domain |