Home >Database >Mysql Tutorial >Why Does My SQL Function Call Fail with 'function does not exist' Error?
Consider the following error message:
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.
In this scenario, an attempt was made to call a function named FnUpdateSalegtab09 with specific parameters. However, the error indicates that the function does not exist. Additionally, the error suggests that there is no function that matches the specified name and argument types.
The error is likely due to a casting issue. In the function call, numeric literals are used for parameters that are defined as smallint in the function definition. Numeric literals are initially presumed to be type integer if their value fits in type integer. Since there is no explicit type cast provided, this can lead to a mismatch between the expected and actual argument types.
To resolve this issue, add explicit type casts to the numeric literals in the function call to match the expected smallint data type. Alternatively, you can use quoted (untyped) literals in the function call.
Incorrect Call:
SELECT * FROM f_typetest(1);
Correct Calls:
SELECT * FROM f_typetest('1'); SELECT * FROM f_typetest(smallint '1'); SELECT * FROM f_typetest(1::int2); SELECT * FROM f_typetest('1'::int2);
By making these adjustments, the function call should now be recognized and executed without the error.
The above is the detailed content of Why Does My SQL Function Call Fail with 'function does not exist' Error?. For more information, please follow other related articles on the PHP Chinese website!