【发布时间】:2021-05-30 14:56:34
【问题描述】:
我用一个简单的函数创建了一个简单的表,为过去的学期插入一些日志:
CREATE TABLE log_elapsedsemester(
sy char(9) NOT NULL,
sem char(1) NOT NULL,
date_recorded TIMESTAMP NOT NULL,
recordedby varchar(255)
);
CREATE OR REPLACE FUNCTION addelapsedsemester(p_sy char,p_sem char,p_date_recorded
TIMESTAMP,p_recordedby varchar)
returns void
AS
$$
BEGIN
insert into log_elapsedsemester (sy,sem,date_recorded,recordedby) values
(p_sy,p_sem,p_date_recorded,p_recordedby);
END
$$
LANGUAGE plpgsql;
但每次我使用
select addelapsedsemester('2019-2020','1',now(),'sample@gmail.com');
我得到错误:
No function matches the given name and argument types. You might need to add explicit type casts.
如果我使用没有任何功能的简单INSERT,它会成功插入:
insert into log_elapsedsemester(sy,sem,date_recorded,recordedby) values ('2020-
2021','1',now(),'sample@gmail.com');
我正在使用 PostgreSQL 9.5 和 pgadmin III。
【问题讨论】:
标签: postgresql function types casting postgresql-9.5