From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-sql@postgresql.org
Subject: Re: Retrieve the column values of a record without knowing the names
Date: Fri, 18 Feb 2011 11:10:00 +0200
Message-ID: <201102181110.00856.achill@matrix.gatewaynet.com> (raw)
In-Reply-To: <1297873099984-3387935.post@n5.nabble.com>
References: <1297873099984-3387935.post@n5.nabble.com>
Στις Wednesday 16 February 2011 18:18:19 ο/η arthur_info έγραψε:
>
> 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?
>
Well by your function, it seems that it does not do what you want.
You want to access the values of one row without knowing the names, but what you do
is create an array over the values of a *known* column.
Also where aluno = ''3043'' does not make any sense either.
Anyways, you might want to look at database metada as found in the information_schema.
For a start you might want to look in information_schema.columns
> 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-n...
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
--
Achilleas Mantzios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: achill@matrix.gatewaynet.com
Subject: Re: Retrieve the column values of a record without knowing the names
In-Reply-To: <201102181110.00856.achill@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox