Hi all.
I'd need to implement a "parametric windowed select" over a table
called "atable". The idea is to have a one row table to maintain
the LIMIT and the OFFSET for the selects. If I try this:
create table limoff( l int, o int );
insert into limoff values ( 10,2 );
select a.* from atable a,limoff limit l offset o;
I get "ERROR: argument of OFFSET must not contain variables".
(You get the error also on LIMIT if you put a constant as the offset).
But I can do the following:
create or replace function f_limoff_1( l int, o int )
returns setof atable as $$
select * from atable limit $1 offset $2
$$ language sql;
create or replace function f_limoff()
returns setof atable as $$
select * from f_limoff_1( (select l from limoff),(select i from limoff) );
$$ language sql;
Of course, in my opinion at least, there's no real reason for the above
syntax limitation, as the sematics is not.
Wouldn't it be a nice enhacement to allow variable LIMIT and OFFSET in
SELECTs?
--
Reg me Please