关于postgresql:plpgsql:没有函数匹配给定的名称和参数类型。 您可能需要添加显式类型转换

plpgsql: No function matches the given name and argument types. You might need to add explicit type casts

我已经使用DBeaver在PostgreSQL中创建了一个存储过程。
&我试图通过从DBeaver调用过程将数据插入表中。
但这给我一个错误

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

程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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$
;

调用过程:

1
SELECT public.proc_insert_test(123, 'Test2', 'Test2', 'T', 'T', now(), 1, 9, 1234, now());

可能是什么问题?

我对此完全陌生。

更新:

过程调用:

1
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

Procedure
Procedure calling


Postgres不允许从timestampdate数据类型的隐式转换。 注意-Postgres date类型与Oracle的date类型不同。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 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的转换丢失了转换。 默认情况下是不允许的。 因此,您应该强制执行它(通过显式强制转换),或者应该使用返回date类型的伪常量current_date,并且没有必要进行任何转换。