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?

Why am I getting the 'ERROR: function ... does not exist' error and how can I fix the type mismatch in my function call?

DDD
DDDOriginal
2025-01-05 14:25:40564browse

Why am I getting the

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!

Statement:
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