Re: Retrieve the column values of a record without knowing the names

Поиск
Список
Период
Сортировка
От Dmitriy Igrishin
Тема Re: Retrieve the column values of a record without knowing the names
Дата
Msg-id AANLkTi=rqcZjF=Q3pcoTyMdLXcAvxLfKOqOOSdw3YFK1@mail.gmail.com
обсуждение исходный текст
Ответ на Retrieve the column values of a record without knowing the names  (arthur_info <arthur_info@yahoo.com.br>)
Ответы Re: Retrieve the column values of a record without knowing the names  (arthur_info <arthur_info@yahoo.com.br>)
Список pgsql-sql
Hey,

2011/2/16 arthur_info <arthur_info@yahoo.com.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?
You can easily iterate across records from PL/pgSQL by using hstore, e.g:
SELECT (avals(hstore(ROW(83,6,4))))[3];
dmitigr=> SELECT (avals(hstore(ROW(83,6,4))))[3] AS thirdfield;
 thirdfield
------------
 4
(1 row)

See http://www.postgresql.org/docs/9.0/static/hstore.html
 

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-tp3387935p3387935.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



--
// Dmitriy.


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

Предыдущее
От: arthur_info
Дата:
Сообщение: Re: Retrieve the column values of a record without knowing the names
Следующее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: Is it possible to get DISTINCT rows from RETURNING clause?