From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | arthur_info <arthur_info(at)yahoo(dot)com(dot)br> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Retrieve the column values of a record without knowing the names |
Date: | 2011-02-18 08:34:46 |
Message-ID: | AANLkTikuw_5gs190=PFqtY+XyH6=L_ZKmQXcB5tjWbFt@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello
you can't simply iterate over record in plpgsql. You can use a some
toolkits like PLToolkit, or different PL language like PLPerl, or some
dirty trick
http://okbob.blogspot.com/2010/12/iteration-over-record-in-plpgsql.html
regards
Pavel Stehule
2011/2/16 arthur_info <arthur_info(at)yahoo(dot)com(dot)br>:
>
> Hello,
>
> I've got the following function and I want to access the fields values of my
> record by index. The problem is that my select is retrieving each record
> line with all values and not each one of each row on my view... How can I
> solve this problem?
>
> Thanks in advance.
>
>
> CREATE FUNCTION fc_teste_tce(aluno integer) RETURNS character varying AS
> $BODY$
> DECLARE
> reg record;
> BEGIN
> for reg in execute 'SELECT ARRAY (SELECT vw_teste_tce FROM
> estagio.vw_teste_tce where aluno = ''3043'' LIMIT 20) AS campos' loop
> for j in 1..array_upper(reg.campos,1) loop
> raise notice 'Field Value: %',reg.campos[j];
> end loop;
> end loop;
> return 'ok';
> END;
> $BODY$
>
> LANGUAGE plpgsql VOLATILE;
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Retrieve-the-column-values-of-a-record-without-knowing-the-names-tp3387932p3387932.html
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2011-02-18 09:10:00 | Re: Retrieve the column values of a record without knowing the names |
Previous Message | Gnanakumar | 2011-02-18 05:58:35 | Re: Is it possible to get DISTINCT rows from RETURNING clause? |