postgresql 没有与给定名称和参数类型匹配的函数

gywdnpxw  于 2023-03-12  发布在  PostgreSQL
关注(0)|答案(1)|浏览(277)
CREATE OR REPLACE FUNCTION public.udf_insertcontact(
    _pid integer,
    _firstname character varying(30),
    _lastname character varying(30),
    _emailaddress character varying(100),
    _company character varying(50),
    _category character varying,
    _gender character varying,
    _dob timestamp,
    _modeslack boolean,
    _modewhatsapp boolean,
    _modeemail boolean,
    _modephone boolean,
    _contactimage character varying)
    RETURNS integer
    LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
    INSERT INTO public.tblcontacts(
     professionid, firstname, lastname, emailaddress, company, category, gender, dob, modeslack, modewhatsapp, modeemail, modephone, contactimage)
    VALUES ( 
        _pid, _firstname, _lastname, _emailaddress, _company, _category, _gender, _dob, _modeslack, _modewhatsapp, _modeemail, _modephone, _contactimage);
    IF FOUND THEN -- INSERTED SUCCESSFULLY
    RETURN 1;
    ELSE RETURN 0; -- INSERTED FAIL
    END IF;                                                                 
END
$BODY$;
SELECT public.udf_insertcontact(2,'first','last','email@e.com','company','Client','Female',current_timestamp,false,true,false,true,'');

错误:函数public.udf_insertcontact(整数,未知,未知,未知,未知,带时区的时间戳,布尔,布尔,布尔,布尔,未知)不存在

wqsoz72f

wqsoz72f1#

您的函数没有问题,您需要对参数current_timestamp::timestamp进行类型转换
这将工作:

SELECT udf_insertcontact(2,'first','last','email@e.com','company','Client','Female',current_timestamp::timestamp,false,true,false,true,'');

Demo here

相关问题