PostgreSQL:如何识别数据类型?
如何识别函数中任意元素的数据类型PostgreSQL:如何识别数据类型?,postgresql,plpgsql,Postgresql,Plpgsql,如何识别函数中任意元素的数据类型 CREATE OR REPLACE FUNCTION test1(par1 int,**par2 anyelement**) RETURNS BOOL AS $$ DECLARE rc bool := true; BEGIN -- ? RETURN rc; END; $$ LANGUAGE plpgsql; 使用: 使用: create or replace function test(par anyelement) returns text
CREATE OR REPLACE FUNCTION test1(par1 int,**par2 anyelement**)
RETURNS BOOL
AS $$
DECLARE rc bool := true;
BEGIN
-- ?
RETURN rc;
END;
$$
LANGUAGE plpgsql;
使用:
使用:
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)