gpt4 book ai didi

postgresql - "function does not exist,"但我真的认为它确实如此

转载 作者:行者123 更新时间:2023-11-29 11:14:10 25 4
gpt4 key购买 nike

我是疯了还是傻了?

dev=# \df abuse_resolve 
List of functions
-[ RECORD 1 ]-------+------------------------------------------------------------------------------------------------------------------------------------
Schema | public
Name | abuse_resolve
Result data type | record
Argument data types | INOUT __abuse_id bigint, OUT __msg character varying
Type | normal

dev=# select abuse_resolve('30'::bigint);
ERROR: function abuse_resolve(bigint) does not exist
LINE 1: select abuse_resolve('30'::bigint);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

这是CREATE FUNCTION,我省略了代码的主要内容,但这应该是无关紧要的:

CREATE OR REPLACE FUNCTION abuse_resolve(INOUT __abuse_id bigint, OUT __msg character varying) RETURNS record AS $_$
DECLARE
__abuse_status VARCHAR;
BEGIN
...snip...
UPDATE abuse SET abuse_status = __abuse_status,
edate = now(),
closed_on = now()
WHERE abuse_id = __abuse_id;
__msg = 'SUCCESS';
END;
$_$ LANGUAGE plpgsql SECURITY DEFINER;

只是为了咯咯笑:

GRANT ALL ON FUNCTION abuse_resolve(INOUT __abuse_id, OUT __msg character varying) TO PUBLIC;
GRANT ALL ON FUNCTION abuse_resolve(INOUT __abuse_id, OUT __msg character varying) TO myuser;

那个函数好像是存在的。我可能缺少什么?

这个解决了,答案是:我傻了。我最初没有正确定义参数,但我的代码使用了正确的参数。有一个额外的 bigint 在那里没有任何业务。

最佳答案

嗯,有点奇怪。我做了:

steve@steve@[local] =# create function abuse_resolve(inout __abuse_id bigint,
out __msg text) returns record language plpgsql as
$$ begin __msg = 'ok'; end; $$;
CREATE FUNCTION
steve@steve@[local] =# \df abuse_resolve
List of functions
-[ RECORD 1 ]-------+----------------------------------------
Schema | so9679418
Name | abuse_resolve
Result data type | record
Argument data types | INOUT __abuse_id bigint, OUT __msg text
Type | normal

steve@steve@[local] =# select abuse_resolve('30'::bigint);
-[ RECORD 1 ]-+--------
abuse_resolve | (30,ok)

您对该数据库有任何其他问题吗?你能用转储/恢复复制它并在新副本上试试这个吗?使用“公共(public)”模式明确限定函数名有帮助吗?您使用的是哪个版本的 PostgreSQL?

更新:sql 函数它也适用于我使用:

create function abuse_resolve(inout __abuse_id bigint, out __msg text)
language sql as $$ select $1, 'ok'::text $$;

关于postgresql - "function does not exist,"但我真的认为它确实如此,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9679418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com