Postgresql plpgsql:没有与给定名称和参数类型匹配的函数。您可能需要添加显式类型转换
我使用DBeaver在PostgreSQL中创建了一个存储过程。 &我试图通过从DBeaver调用过程将数据插入表中。 但这给了我一个错误 SQL错误[42883]:错误:函数public.proc_insert_test(整数、未知、未知、未知、带时区的时间戳、整数、整数、整数、带时区的时间戳)不存在 提示:没有与给定名称和参数类型匹配的函数。您可能需要添加显式类型转换。 职位:8 程序:Postgresql plpgsql:没有与给定名称和参数类型匹配的函数。您可能需要添加显式类型转换,postgresql,plpgsql,Postgresql,Plpgsql,我使用DBeaver在PostgreSQL中创建了一个存储过程。 &我试图通过从DBeaver调用过程将数据插入表中。 但这给了我一个错误 SQL错误[42883]:错误:函数public.proc_insert_test(整数、未知、未知、未知、带时区的时间戳、整数、整数、整数、带时区的时间戳)不存在 提示:没有与给定名称和参数类型匹配的函数。您可能需要添加显式类型转换。 职位:8 程序: CREATE OR REPLACE FUNCTION public.proc_insert_test(p
CREATE OR REPLACE FUNCTION public.proc_insert_test(p_brndcode integer,
p_brndname varchar(100),
p_brndsname varchar(100),
p_prdtype char(1),
p_discontinue char(1),
p_crddate date,
p_status integer,
p_recstat integer,
p_brndgrpseqno integer,
p_wefrom date)
RETURNS char
LANGUAGE plpgsql
AS $body$
BEGIN
Insert into arc_mmstbrndgroup(brndcode, brndname, brndsname, prdtype, discontinue, crddate, status, recstat, brndgrpseqno, wefrom)
values(p_brndcode, p_brndname, p_brndsname, p_prdtype, p_discontinue, p_crddate, p_status, p_recstat, p_brndgrpseqno, p_wefrom);
END;
$body$
;
调用过程:
select public.proc_insert_test(123, 'Test2', 'Test2', 'T', 'T', now(), 1, 9, 1234, now());
问题是什么
我对这个完全陌生
更新:
过程调用:
select public.proc_insert_test(123, 'Test2'::varchar(100), 'Test2'::varchar(100), 'T'::char(1), 'T'::char(1), now(), 1, 9, 1234, now());
错误:
SQL错误[42883]:错误:函数public.proc_insert_测试(整数、字符变化、字符、字符、带时区的时间戳、整数、整数、整数、带时区的时间戳)不存在
提示:没有与给定名称和参数类型匹配的函数。您可能需要添加显式类型转换。
职位:8
Postgres不允许从
时间戳
隐式转换为日期
数据类型。注意-Postgresdate
类型与Oracle的date
类型不同
CREATE OR REPLACE FUNCTION public.test(v date)
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
RAISE NOTICE '%', v;
END;
$function$
postgres=# SELECT test(now());
ERROR: function test(timestamp with time zone) does not exist
LINE 1: SELECT test(now());
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
postgres=# SELECT test(current_date);
NOTICE: 2019-11-14
+------+
| test |
+------+
| |
+------+
(1 row)
postgres=# SELECT test(now()::date);
NOTICE: 2019-11-14
+------+
| test |
+------+
| |
+------+
(1 row)
从
时间戳
(now()
函数的结果类型)到日期
的转换正在丢失转换。默认情况下不允许这样做。因此,您应该强制执行它(通过显式强制转换),或者您应该使用伪常量current\u date
,它返回date
类型,并且不需要任何转换。函数中的所有参数都需要类型当您在函数中使用“varchar”时,这个问题很常见-如果您在调用中使用值“Test2”等,postgresql将其解释为文本类型。与“char”类型相同。因此,您需要在函数调用中特别强制转换这些类型,如“Test2”::varchar(100)等。您能检查一下您只有一个具有预期签名的函数吗?有可能是由于函数重载,PostgreSQL引用了另一个函数。@JosMac尝试了你的建议,但我还是得到了同样的错误。检查我是否已更新我的问题您的功能需要日期now()
返回时间戳。尝试改用当前日期。