我的功能是:
CREATE OR REPLACE FUNCTION FnUpdateSalegtab09
(
iacyrid Integer,iRepId Integer,iDrId Integer,ivrid Integer,imode smallint,itrno
varchar,itrdate timestamp,iacid Integer,ivrno varchar,iSuppId Integer,icustname
varchar,inetamt money,idisrate real,idisamt money,iRoundOff real,ijrmid integer,iuserid
integer,iuserdtm timestamp,iVSNo integer,iRecdAmt money,icstrate real,icstsaleamt
money,icstamt money,itdrate real,itdamt money,icdrate real,icdamt money,iCessRate
real,iCessAmt money,iodesc1 varchar,ioamt1 money,iCashCredit boolean,iOrderNo
varchar,iOrderDate timestamp,iCustAdd2 varchar,iRemarks varchar,iWhoRetSl boolean,iPatName
varchar,iDrName varchar,iFormId integer,iSalesMan varchar,iCFMode smallint,iPatId
integer,iStkPtId integer,iDisType smallint,iBranchID integer
)
RETURNS void AS
'BEGIN
INSERT INTO gtab09
(
acyrid, RepId, DrId, vrid, mode, trno, trdate, acid, vrno, SuppId, custname, netamt,
disrate, disamt, RoundOff, jrmid, userid, userdtm, VSNo, RecdAmt, cstrate, cstsaleamt,
cstamt, tdrate, tdamt, cdrate, cdamt, CessRate, CessAmt, odesc1, oamt1, CashCredit,
OrderNo, OrderDate, CustAdd2, Remarks, WhoRetSl, PatName, DrName, FormId, SalesMan,
CFMode,PatId,StkPtId,DisType,BranchID
)
values
( iacyrid,iRepId,iDrId,ivrid,imode,itrno,itrdate,iacid,ivrno,iSuppId,icustname,inetamt,idisra
te,idisamt,iRoundOff,ijrmid,iuserid,iuserdtm,iVSNo,iRecdAmt,icstrate,icstsaleamt,icstamt,it
drate,itdamt,icdrate,icdamt,iCessRate,iCessAmt,iodesc1,ioamt1,iCashCredit,iOrderNo,iOrderDa
te,iCustAdd2,iRemarks,iWhoRetSl,iPatName,iDrName,iFormId,iSalesMan,iCFMode,iPatId,iStkPtId,
iDisType,iBranchID);
END;'
LANGUAGE plpgsql VOLATILE
COST 100;
我以前称之为:
select FnUpdateSalegtab09 (4, 1, 0, 12, 1, '9'::varchar,'2014-07-15'::timestamp, 4048, '9'::varchar, 4048, 'MYCUSTOMER'::varchar, 12::money, 0, 0::money, 0.32, 185, 0, '2014-07-15 11:24:12 AM'::timestamp, 0, 0::money, 0, 0::money, 0::money, 0, 0::money, 0, 0::money, 0, 0::money, ''::varchar, 0::money, False, ''::varchar, '2014-07-15'::timestamp, ''::varchar, ''::varchar, False, ''::varchar, ''::varchar, 1, ''::varchar, 1,0,1,0,42)
错误是:
ERROR: function fnupdatesalegtab09(integer, integer, integer, integer, integer, unknown, unknown, integer, unknown, integer, unknown, integer, integer, integer, numeric, integer, integer, unknown, integer, integer, integer, integer, integer, integer, integer, integer, integer, integer, integer, unknown, integer, boolean, unknown, unknown, unknown, unknown, boolean, unknown, unknown, integer, unknown, integer, integer, integer, integer, integer) does not exist LINE 1: select FnUpdateSalegtab09 (4, 1, 0, 12, 1, '9','2014-07-15',... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. ********** Error **********
答案 0 :(得分:19)
您的功能有几个 smallint
参数
但是在调用中,您使用的数字文字被假定为类型integer
。
字符串文字或string constant('123'
)不会立即输入。在明确指定或投射之前,它仍为“未知”类型。
但是,会立即输入数字文字或 numeric constant 。 Per documentation:
既不包含小数点也不包含小数点的数字常量 指数最初假设为
integer
,如果它的值 适合类型integer
(32位);否则它被认为是类型bigint
如果其值适合类型bigint
(64位);否则就是 被认为是numeric
类型。包含小数点和/或的常量 指数最初总是被假定为numeric
类型。
此相关答案中有更多解释和链接:
为smallint
参数添加显式强制转型或引用它们。
CREATE OR REPLACE FUNCTION f_typetest(smallint)
RETURNS bool AS 'SELECT TRUE' LANGUAGE sql;
呼叫不正确:
SELECT * FROM f_typetest(1);
纠正电话:
SELECT * FROM f_typetest('1');
SELECT * FROM f_typetest(smallint '1');
SELECT * FROM f_typetest(1::int2);
SELECT * FROM f_typetest('1'::int2);
答案 1 :(得分:1)
该错误意味着函数调用仅与现有函数匹配,如果其所有参数的类型相同且以相同顺序传递。所以,如果下一个f()
函数
create function f() returns integer as $$
select 1;
$$ language sql;
被称为
select f(1);
会出错
ERROR: function f(integer) does not exist
LINE 1: select f(1);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
因为没有f()
函数将整数作为参数。
因此,您需要仔细比较传递给函数的内容与预期内容。那长长的表列列表看起来很糟糕。
答案 2 :(得分:0)
在我的特定情况下,该功能实际上已丢失。错误消息是相同的。我正在使用Postgresql插件PostGIS,我不得不重新安装它。无论出于何种原因。
答案 3 :(得分:0)
我通过 Google 搜索找到了这个问题 - 我遇到了同样的错误
<块引用>没有函数匹配给定的名称和参数类型
但与 OP 不同,在我的例子中是因为函数存在,但它在不同的架构中。
要验证这种情况,需要运行查询:
SELECT
n.nspname AS function_schema,
p.proname AS function_name
FROM
pg_proc p
LEFT JOIN pg_namespace n ON p.pronamespace = n.oid
WHERE
n.nspname NOT IN ('pg_catalog', 'information_schema')
AND p.proname ILIKE '%your_function_name%'
ORDER BY
function_schema,
function_name;
以防万一有人遇到同样的问题。