- CREATE OR REPLACE function fun_getRecSeq_range(p_dt timestamp) returns record
- as
- $BODY$
- declare c_str varchar;
- declare ret record;
- begin
- c_str:='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$.`';
- select (substr(c_str,extract(YEAR from p_dt)::int-2010+1,1)||
- substr(c_str,extract(month from p_dt)::int+1,extract(day from p_dt)::int+1,1) )::varchar as seqStart,(substr(c_str,1)||'ZZZZ')::varchar as seqEnd
- into ret ;
- return ret ;
- end;
- $BODY$
- LANGUAGE plpgsql VOLATILE
- COST 100;
- select * from fun_getRecSeq_range(current_date) as (seqStart varchar,seqEnd varchar)
上面例子将日期转为recseq的范围,单条记录的,若要用多条记录,要用set of record ...