I have made a function in postgres
CREATE OR REPLACE FUNCTION foobar(
x TEXT,
y TEXT,
z REAL
) RETURNS BOOLEAN AS $func$
.
.
.
$func$ LANGUAGE plpgsql;
When I do \df i get the following:
+----------+--------+------------------+------------------------+---------+
| Schema | Name | Result data type | Argument data types | Type |
+----------+--------+------------------+------------------------+---------+
| mySchema | foobar | boolean | x text, y text, z real | normal |
+----------+--------+------------------+------------------------+---------+
But when I try to use it I get [42883] ERROR: function foobar(text, text, real) does not exist. Hint: No function matches the given name and argument types. You might need to add explicit type casts. The call I'm doing is:
SELECT * FROM myTable WHERE foobar(column1::text, 'hello'::text, 7.2::real);
To me it seems like the function exists and the types match, I'm struggling to figure out what's wrong.
As a_horse_with_no_name mentioned in his comment, the solution is prefix the function with the schema.
Wrong: SELECT * FROM myTable WHERE foobar(column1::text, 'hello'::text, 7.2::real);
Correct: SELECT * FROM myTable WHERE mySchema.foobar(column1::text, 'hello'::text, 7.2::real);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With