Reputation: 4151
Given the following Postgresql routine:
CREATE OR REPLACE FUNCTION checkemailexists (emailaddress text) RETURNS boolean
LANGUAGE plpgsql
AS $$
#print_strict_params on
DECLARE
existsCount int;
BEGIN
SELECT count(*) INTO STRICT existsCount
FROM usercontacts WHERE usercontacts.contactaddress = emailAddress;
IF existsCount > 0 THEN RETURN TRUE;
ELSE RETURN FALSE;
END IF;
END
$$
And the following .NET (Npgsql) block:
public bool EmailExists(string email)
{
using (var conn = Connection)
{
conn.Open();
using(var tran = conn.BeginTransaction())
using (var cmd = new NpgsqlCommand("checkemailexists", conn))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@emailAddress",NpgsqlTypes.NpgsqlDbType.Text ,"[email protected]");
var ret = (bool)cmd.ExecuteScalar();
return ret;
}
}
}
I keep getting the following error
PostgresException: 42883: function checkemailexists(emailAddress => text) does not exist
I'm a total newb to postgres and I'm not being very successful finding a relevant answer searching.
Can you please help me understand why this function cannot be found when I try to call it?
SELECT version();
PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413, 64-bit
.NET Core
Npgsql 3.1.9
Thank you!
Upvotes: 2
Views: 10129
Reputation: 1
PostgresException: 42883: function checkemailexists(emailAddress => text) does not exist
ANS=>Postgre is case sensitive, so always check proper function name & parameters name
Upvotes: -1
Reputation: 4151
Welp... Case Sensitive is the phrase of the day.
emailAddress != emailaddress
Upvotes: 8