我正在创建一个创造良好的功能,但是当我调用它时会出现问题。
CREATE OR REPLACE FUNCTION public.winner_pagination(
_searchText varchar,
_sort varchar, _order char(3), _limit int, _offset int)
RETURNS SETOF RECORD AS
$BODY$
DECLARE
BEGIN
RETURN QUERY SELECT CREATED_DATE as createddate, DELETED AS deleted, FIRST_NAME AS firstname, LAST_NAME AS lastname,
NO_OF_AWARDS AS noofawards, PHONE AS phone, COUNTRY_ID AS country, ORGId_ID AS orgId , EMAIL as email
FROM winner
WHERE deleted = false
and ORGId_ID = 1
and first_name LIKE _searchText OR last_name LIKE _searchText OR email LIKE _searchText OR phone LIKE _searchText
order by _sort limit _limit offset _offset;
END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION public.winner_pagination(varchar, varchar, char(3), int, int)
OWNER TO postgres;
我正在调用这个函数
select * from winner_pagination('Arthur', 'firstname', 'asc', 9, 0)
as f(createddate date, deleted boolean, firstname varchar, lastname varchar, noofawards integer ,
phone varchar, country integer, orgId integer, email varchar ) ;
ERROR: structure of query does not match function result type
SQL state: 42804
Detail: Returned type timestamp without time zone does not match expected type date in column 1.
Context: PL/pgSQL function winner_pagination(character varying,character varying,character,integer,integer) line 6 at RETURN QUERY