Error: No function matches the given name and argument types

只谈情不闲聊 提交于 2019-12-13 04:56:58

问题


I try to get this function running. When I use pgadmin and manually call this function with

SELECT calculate_something(7) or SELECT common.calculate_something(7)

ERROR: function calculate_something(integer) doesn't exist hint no function matches the given name and argument types (translated from german)

I already tried to cast the call SELECT calculate_something(cast(7 as bigint));

What is wrong with that function or cast? :/

CREATE OR REPLACE FUNCTION common.calculate_something(id bigint)
  RETURNS real AS
$BODY$
  DECLARE
    some_value_out REAL := 20;
  BEGIN
    -- I already removed that part for bug fixing and return a constant value (20)
    RETURN some_value_out;
  END;
$BODY$
  LANGUAGE plpgsql VOLATILE;

回答1:


Is your function actually called:

stoff_stueckgewicht(id bigint)

Or perhaps:

stoff_stückgewicht(id bigint)

?

The latter is a likely cause of problems if your locale settings are different between debian and PostgreSQL.

Alternatively, go through all the functions in all of the schemas on your database, using pgAdmin III and find the function manually.




回答2:


Use this to diagnose your problem:

SELECT n.nspname AS schema, p.proname AS function
     , pg_get_function_identity_arguments(p.oid) As args
FROM   pg_proc p
JOIN   pg_namespace n ON n.oid = p.pronamespace
WHERE  p.proname LIKE 'calculate%';
  • How to get function parameter lists (so I can drop a function)

And check your search_path:

  • How does the search_path influence identifier resolution and the "current schema"

Either way, a bigint function can be called with a numeric literal - defaulting to integer, but there is a registered cast to bigint.

Consider Function Type Resolution:

  • PostgreSQL function call
  • Is there a way to disable function overloading in Postgres


来源:https://stackoverflow.com/questions/36126429/error-no-function-matches-the-given-name-and-argument-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!