Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 43239133798E for ; Fri, 18 Feb 2011 05:10:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 69719-01 for ; Fri, 18 Feb 2011 09:10:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id 1587F1336FA7 for ; Fri, 18 Feb 2011 05:10:03 -0400 (AST) Received: from smadev.internal.net (localhost.internal.net [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id p1I9A1J0036302 for ; Fri, 18 Feb 2011 11:10:01 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id p1I9A0OG036298 for pgsql-sql@postgresql.org; Fri, 18 Feb 2011 11:10:00 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt 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 User-Agent: KMail/1.9.7 References: <1297873099984-3387935.post@n5.nabble.com> In-Reply-To: <1297873099984-3387935.post@n5.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201102181110.00856.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.671 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_BRBL_LASTEXT=1.449, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201102/98 X-Sequence-Number: 35174 =CE=A3=CF=84=CE=B9=CF=82 Wednesday 16 February 2011 18:18:19 =CE=BF/=CE=B7 = arthur_info =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: >=20 > Hello, >=20 > 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?=20 >=20 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 wha= t you do is create an array over the values of a *known* column. Also where aluno =3D ''3043'' does not make any sense either. Anyways, you might want to look at database metada as found in the informat= ion_schema. =46or a start you might want to look in information_schema.columns > Thanks in advance. >=20 >=20 > CREATE FUNCTION fc_teste_tce(aluno integer) RETURNS character varying AS > $BODY$=20 > DECLARE > reg record; > BEGIN > for reg in execute 'SELECT ARRAY (SELECT vw_teste_tce FROM > estagio.vw_teste_tce where aluno =3D ''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; =20 > $BODY$ >=20 > LANGUAGE plpgsql VOLATILE; >=20 >=20 > --=20 > View this message in context: http://postgresql.1045698.n5.nabble.com/Ret= rieve-the-column-values-of-a-record-without-knowing-the-names-tp3387935p338= 7935.html > Sent from the PostgreSQL - sql mailing list archive at Nabble.com. >=20 =2D-=20 Achilleas Mantzios