Home >Database >Mysql Tutorial >Why am I getting the 'ERROR: function ... does not exist' error and how can I fix the type mismatch in my function call?
Understanding the Error: "ERROR: function ... does not exist and HINT: No function matches the given name and argument types"
When attempting to execute a function, it's crucial to ensure that the specified function name and argument types match the actual function definition. If there's a mismatch, you'll likely encounter the error "ERROR: function ... does not exist and HINT: No function matches the given name and argument types."
Solution: Examining Argument Types
In this specific scenario, the error is related to a type mismatch for the "smallint" parameters in your function definition. However, in the function call, you're using numeric literals that are presumed to be of type "integer."
Understanding Numeric Literals
A string literal (like '123') is initially untyped and remains so until its value is assigned or explicitly cast. However, numeric literals (like 123) are immediately typed as "integer" if they fit within the allowed range, and as "bigint" or "numeric" if they exceed that range.
Resolving the Mismatch
To resolve the issue, you have two options:
Add Explicit Casts: Add explicit casts for the "smallint" parameters in the function call:
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)
Pass Untyped Literals: Pass quoted (untyped) literals for the "smallint" parameters:
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)
The above is the detailed content of Why am I getting the 'ERROR: function ... does not exist' error and how can I fix the type mismatch in my function call?. For more information, please follow other related articles on the PHP Chinese website!