Home > Database > Mysql Tutorial > Why Does My SQL Function Call Fail with 'function does not exist' Error?

Why Does My SQL Function Call Fail with 'function does not exist' Error?

Mary-Kate Olsen
Release: 2024-12-27 09:33:11
Original
266 people have browsed it

Why Does My SQL Function Call Fail with

ERROR: Function Does Not Exist and No Matching Function Found

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.  
Copy after login

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.

Root Cause

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.

Solution

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.

Example

Incorrect Call:

SELECT * FROM f_typetest(1);
Copy after login

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);
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template