小编Kor*_*zay的帖子

postgresql 执行带有参数的存储过程

我的 Npgsql 版本 3.2.5 - Postgresql 9.6

我收到此错误CommandType.StoredProcedure(但CommandType.Text有效):

Npgsql.PostgresException:'42883:函数 customer_select(pEmail => 文本,密码 => 文本) 不存在'

string sql3 = @"customer_select";

NpgsqlConnection pgcon = new NpgsqlConnection(pgconnectionstring);
pgcon.Open();
NpgsqlCommand pgcom = new NpgsqlCommand(sql3, pgcon);
pgcom.CommandType = CommandType.StoredProcedure;
pgcom.Parameters.AddWithValue(":pEmail", "myemail@hotmail.com");
pgcom.Parameters.AddWithValue(":pPassword", "eikaylie78");
NpgsqlDataReader pgreader = pgcom.ExecuteReader();

while (pgreader.Read()) {
    string name = pgreader.GetString(1);
    string surname = pgreader.GetString(2);
}
Run Code Online (Sandbox Code Playgroud)

这是数据库中的函数:

CREATE OR REPLACE FUNCTION public.customer_select(
    pemail character varying, ppassword character varying)
RETURNS SETOF "CustomerTest"
LANGUAGE 'plpgsql'
COST 100.0
AS $function$                                   
BEGIN …
Run Code Online (Sandbox Code Playgroud)

c# postgresql stored-functions npgsql

5
推荐指数
1
解决办法
3万
查看次数

PostgreSQL 11 - 过程支持

  • PostgreSql 版本:11 Beta 4
  • Npgsql 版本:v4.0.3

我想测试 PostgreSql 的 Store Prodecure,但出现错误。

"42809: get_customer_list() is a procedure"
Run Code Online (Sandbox Code Playgroud)

我的命令类型

CommandType.StoredProcedure
Run Code Online (Sandbox Code Playgroud)

Npgsql 是否支持 PostgreSql 11 Store Prodecure ?

postgresql npgsql

3
推荐指数
1
解决办法
504
查看次数

标签 统计

npgsql ×2

postgresql ×2

c# ×1

stored-functions ×1