I'm rookie to plpgsql, I've created a stored procedure to get the table data into refcursor and I'm trying to call the procedure from plpgsql and c# to check if the procedure/c# code is working fine.
Procedure:
CREATE OR REPLACE FUNCTION public.proc_get_test(out tbldata refcursor)
returns refcursor
LANGUAGE plpgsql
AS $function$
BEGIN
open tbldata for
select * from arc_mmstbrndgroup;
END;
$function$;
Calling procedure from plpgsql:
SELECT proc_get_test('cur');
Then tried fetching data from refcursor:
FETCH ALL FROM cur;
SQL Error [34000]: ERROR: cursor " cur " does not exist
Another way tried:
BEGIN;
SELECT proc_get_test('cur');
FETCH ALL FROM cur;
COMMIT;
Output:
C#:
var p = new PostgreSQLDynamicParameters();
p.Add("tbldata", dbType: NpgsqlDbType.Refcursor, direction: ParameterDirection.Output);
using (var multi = _connection.QueryMultiple("proc_get_test", param: p, commandType: CommandType.StoredProcedure))
{
List<PostgresModel> dataMaster = multi.Read<PostgresModel>().AsList();
return new ResponseModel { ResultSet = dataMaster, StatusCode = 1, StatusDescription = "Success" };
}
Api receiving only 1 row that too with null values
Can anyone help me with calling the procedure in plpgsql and c#?


SELECT * FROMis bad practice. Specifying columns by name and type will save you many problems in the long run.