Home > Database > Mysql Tutorial > Why Does My SQL Function Call Fail with 'function ... does not exist' and How Can I Fix It?

Why Does My SQL Function Call Fail with 'function ... does not exist' and How Can I Fix It?

Susan Sarandon
Release: 2024-12-27 13:03:16
Original
752 people have browsed it

Why Does My SQL Function Call Fail with

"ERROR: function ... does not exist and HINT: No function matches the given name and argument types"

In the provided code, an attempt is made to call the function FnUpdateSalegtab09. However, an error is encountered, indicating that the function does not exist or its argument types do not match the expected ones.

The error message suggests that the function name or the argument types might be incorrect. Let's investigate the possible causes.

Argument Types Compatibility

The function signature for FnUpdateSalegtab09 specifies that several of its parameters are of type smallint. However, in the function call, these parameters are being passed as numeric literals, which are initially presumed to be of type integer.

This mismatch between the expected and actual types of the arguments can result in the error.

Solution

To resolve this issue, you need to explicitly cast the numeric literals to the correct type, smallint, before passing them to the function. You can achieve this by adding a type cast operator (::) to each literal, as shown below:

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

By adding the explicit type casts, you ensure that the argument types match the expectations of the function definition, and the function call should now execute without the "function ... does not exist" error.

The above is the detailed content of Why Does My SQL Function Call Fail with 'function ... does not exist' and How Can I Fix It?. 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