Project

General

Profile

« Previous | Next » 

Revision 8325

schemas/util.sql: Added mk_subset_by_row_num_func()

View differences:

util.sql
836 836

  
837 837

  
838 838
--
839
-- Name: mk_subset_by_row_num_func(regclass, text); Type: FUNCTION; Schema: util; Owner: -
840
--
841

  
842
CREATE FUNCTION mk_subset_by_row_num_func(view_ regclass, row_num_col text) RETURNS void
843
    LANGUAGE plpgsql STRICT
844
    AS $_$
845
BEGIN
846
	EXECUTE $$
847
CREATE OR REPLACE FUNCTION $$||view_||$$(limit_ integer DEFAULT NULL::integer, offset_ integer DEFAULT NULL)
848
  RETURNS SETOF $$||view_||$$ AS
849
$BODY1$
850
SELECT * FROM $$||util.type_qual_name(view_::text::regtype)||$$
851
WHERE $$||quote_ident(row_num_col)||$$ BETWEEN COALESCE($2, 0) AND COALESCE($2+$1, 2147483647)
852
$BODY1$
853
  LANGUAGE sql STABLE
854
  COST 100
855
  ROWS 1000
856
$$;
857
END;
858
$_$;
859

  
860

  
861
--
839 862
-- Name: name(regtype); Type: FUNCTION; Schema: util; Owner: -
840 863
--
841 864

  

Also available in: Unified diff