Re: Record with a field consisting of table rows
От | Jon Smark |
---|---|
Тема | Re: Record with a field consisting of table rows |
Дата | |
Msg-id | 683638.47205.qm@web112803.mail.gq1.yahoo.com обсуждение исходный текст |
Ответ на | Re: Record with a field consisting of table rows (Alban Hertroys <dalroi@solfertje.student.utwente.nl>) |
Ответы |
Re: Record with a field consisting of table rows
|
Список | pgsql-general |
Hi, > Nope, see my reply from yesterday around 20:23 > You can return a table instead, with the count added as an > extra column. I did see your solution, but note that it does not return a tuple consisting of an integer and a setof (as I wanted), but instead returns a setof of a tuple. I still haven't found a solution to the original problem. The best I can do so far is to create a function that returns a tuple consisting of an int and the first row of table results (see below). Any more thoughts? Best regards, Jon create table users ( uid int4 not null, name text not null, age int4 not null, primary key (uid) ); create type page_t AS ( total int4, users users ); create function get_page () returns page_t language plpgsql as $$ declare _total int4; _users users; _page page_t; begin select count (*) from users into _total; select * from users limit 10 into _users; _page := row (_total, _users); return _page; end $$;
В списке pgsql-general по дате отправления: