【发布时间】:2015-09-08 04:09:08
【问题描述】:
我有以下plpgsql函数:
CREATE OR REPLACE FUNCTION test_func(OUT pid bigint)
RETURNS bigint AS
$BODY$
DECLARE
current_time timestamp with time zone = now();
BEGIN
INSERT INTO "TEST"(
created)
VALUES (current_time) RETURNING id INTO pid;
END
$BODY$
LANGUAGE plpgsql;
select * from test_func();
上面给出了一个错误:
column "created" is of type timestamp with time zone but expression is of type time with time zone
无功能的插入查询:
INSERT INTO "TEST"(
created)
VALUES (now()) RETURNING id INTO pid;
或者如果直接使用now() 而不定义变量,它可以工作。
【问题讨论】:
标签: postgresql timestamp plpgsql