如何识别函数内任意元素的数据类型?
CREATE OR REPLACE FUNCTION test1(par1 int,**par2 anyelement**)
RETURNS BOOL
AS $$
DECLARE rc bool := true;
BEGIN
-- ?
RETURN rc;
END;
$$
LANGUAGE plpgsql;
答案 0 :(得分:3)
create or replace function test(par anyelement)
returns text language plpgsql as $$
begin
return pg_typeof(par)::text;
end $$;
select test(100::int), test('2012-12-12'::date);
test | test
---------+------
integer | date
(1 row)