Wjd*_*is5 0 c# postgresql npgsql
鉴于以下Postgresql例程:
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
$$
Run Code Online (Sandbox Code Playgroud)
以下.NET(Npgsql)块:
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 ,"my@email.com");
var ret = (bool)cmd.ExecuteScalar();
return ret;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我一直收到以下错误
PostgresException: 42883: function checkemailexists(emailAddress => text) does not exist
我是postgres的新手,我找不到相关的答案也不是很成功.
你能帮我理解为什么当我试着打电话时找不到这个功能吗?
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核心
Npgsql 3.1.9
谢谢!
| 归档时间: |
|
| 查看次数: |
3245 次 |
| 最近记录: |