plpgsql:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换
plpgsql: No function matches the given name and argument types. You might need to add explicit type casts
我使用 DBeaver 在 PostgreSQL 中创建了一个存储过程。
&我试图通过从 DBeaver 调用过程将数据插入 table。
但它给我一个错误
SQL Error [42883]: ERROR: function public.proc_insert_test(integer, unknown, unknown, unknown, unknown, timestamp with time zone, integer, integer, integer, timestamp with time zone) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 8
程序:
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 Error [42883]: ERROR: function public.proc_insert_test(integer, character varying, character varying, character, character, timestamp with time zone, integer, integer, integer, timestamp with time zone) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 8
Postgres 不允许从 timestamp
到 date
数据类型的隐式转换。注意 - Postgres date
类型不同于 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)
从 timestamp
(now()
函数的结果类型)到 date
的转换丢失了转换。默认情况下不允许。所以你应该强制执行它(通过显式转换),或者你应该使用 returns date
类型的伪常量 current_date
,并且不需要任何转换。
我使用 DBeaver 在 PostgreSQL 中创建了一个存储过程。 &我试图通过从 DBeaver 调用过程将数据插入 table。 但它给我一个错误
SQL Error [42883]: ERROR: function public.proc_insert_test(integer, unknown, unknown, unknown, unknown, timestamp with time zone, integer, integer, integer, timestamp with time zone) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 8
程序:
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 Error [42883]: ERROR: function public.proc_insert_test(integer, character varying, character varying, character, character, timestamp with time zone, integer, integer, integer, timestamp with time zone) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 8
Postgres 不允许从 timestamp
到 date
数据类型的隐式转换。注意 - Postgres date
类型不同于 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)
从 timestamp
(now()
函数的结果类型)到 date
的转换丢失了转换。默认情况下不允许。所以你应该强制执行它(通过显式转换),或者你应该使用 returns date
类型的伪常量 current_date
,并且不需要任何转换。