Re: Multidimensional array definition in composite type appears parsed as string

Поиск
Список
Период
Сортировка
От miller_2555
Тема Re: Multidimensional array definition in composite type appears parsed as string
Дата
Msg-id 23750913.post@talk.nabble.com
обсуждение исходный текст
Ответ на Multidimensional array definition in composite type appears parsed as string  (miller_2555 <nabble.30.miller_2555@spamgourmet.com>)
Ответы Re: Multidimensional array definition in composite type appears parsed as string  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: miller_2555
Дата:
Сообщение: Re: Multidimensional array definition in composite type appears parsed as string
Следующее
От: Dave Page
Дата:
Сообщение: Re: Postgres registry access using java