Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL:如何识别数据类型?_Postgresql_Plpgsql - Fatal编程技术网

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)