我是疯了还是只是愚蠢的?
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
没有业务。
答案 0 :(得分:3)
嗯,有点奇怪。我做了:
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)
您对此数据库有任何其他问题吗?你可以用dump / restore复制它并在新副本上试试吗?是否使用“public”模式帮助明确限定函数名称?您使用的是哪个版本的PostgreSQL?
更新:sql函数 它对我来说也很好用:
create function abuse_resolve(inout __abuse_id bigint, out __msg text)
language sql as $$ select $1, 'ok'::text $$;
答案 1 :(得分:3)
如果可以,如果是那个问题。我建议使用
"set search_path = mainSchemaName, secondOnes"
设置创建函数的正确模式,或者在调用它的地方直接指定模式名称
select schemaName.abuse_resolve('30'::bigint);
答案 2 :(得分:1)
试试这个语法:
SELECT * FROM abuse_resolve('30'::bigint);
答案 3 :(得分:0)
我拥有一切,但没有使用架构。授予使用架构修复它。