PostgreSQL 9.3:函数不是唯一错误 [英] PostgreSQL 9.3: Function is not unique error
问题描述
我已经用11个参数创建了以下函数,如下所示:
I have created the following function with 11 parameters as shown in below:
函数调用:
SELECT * FROM function_TableDetails
(
NULL::Type_Table,
'2671ffdb-28a4-4ce4-a226-e5a21d66509e',
'D09636DC-0185-4FFC-AEDD-63895B445CD8',
'Xyz',
'Cola',
'20028243-52c2-4d23-a6fe-c3694aab84a2',
'01-01-2000',
'01-01-2016',
'00:00:01',
'23:59:59',
'Al'
);
对接以下错误:
ERROR: function function_TableDetails(Type_Table, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown) is not unique
LINE 1: SELECT * FROM function_TableDetails
^
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
我对此有两个疑问:
第一:如何解决以上错误? (因为它甚至不在函数内,并且没有显示错误的确切位置)
First: How to resolve the above error? (Because it is not even going within the function and not showing exact location of error)
第二:如何调试函数? (特别是必须处理此类错误)
Second: How to debugg the function? (Specially have to work on such type of errors)
推荐答案
您有两个或多个名为 function_TableDetails的函数
并期望有11个参数,尽管某些参数的类型不同。您的字符串参数是无类型的,因此Postgres无法找出您想要的函数。
You have two or more functions named function_TableDetails
and expecting 11 arguments, though the types of some arguments are different. Your string arguments are untyped, so Postgres can't figure out which function you want.
此查询将显示以下每个函数的签名:
This query will show the signature of each of these functions:
SELECT oid::regprocedure
FROM pg_proc
WHERE proname = 'function_tabledetails'
如果您无意间创建了这些,只需删除不需要的即可。否则,请将您的参数强制转换为与您尝试调用的参数期望的类型相匹配。
If you created these inadvertently, just drop the ones you don't want. Otherwise, cast your arguments to match the types expected by the one you're trying to call.
这篇关于PostgreSQL 9.3:函数不是唯一错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!