I have tried to execute the codes below to search for a username
using (var cmd = new NpgsqlCommand("search_users", conn))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username", NpgsqlTypes.NpgsqlDbType.Text, "xxx");
using (var reader = cmd.ExecuteReader())
while (reader.Read())
x.Add(reader["loginname"].ToString());
}
On the line of cmd.ExecuteReader()
I'm getting this error
Npgsql.PostgresException: '42601: a column definition list is required for functions returning "record"'
Am I doing the right way to read the returned records ? This is the stored procedure
CREATE FUNCTION search_users(username TEXT) RETURNS RECORD AS $$
DECLARE
ret RECORD;
BEGIN
SELECT * from public."Users" as t1
WHERE t1."LoginName" = username INTO ret;
RETURN ret;
END;$$ LANGUAGE plpgsql;
Any help is greatly appreciated.