I'm looking for a possibility to retrieve multiple DataTables (within one DataSet), using npgsql and a postgres function (stored procedure). Though my postgres function in general works already, I don't get back 2 separate tables, but only one table, containing all results of all queries (both when executing the function via pgAdmin and via npgsql / NpgsqlDataAdapter.Fill).
See my simplified sample here:
CREATE OR REPLACE FUNCTION "MyFunction"(_parameter character varying)
RETURNS SETOF "MyView" AS
$BODY$
DECLARE
BEGIN
return query SELECT * FROM "MyView" WHERE "Col1" = 'A' AND "Col2" = _parameter;
return query SELECT * FROM "MyView" WHERE "Col1" = 'B' AND "Col2" = _parameter;
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100
ROWS 1000;
Using caller:
SELECT * FROM "MyFunction"('abc');
Isn't there ANY way to get returned a DataSet containing SEPARATE DataTables using npgsql.dll? The query must not necessarily be via a postgres function - if it wpuld be possible to get such DataSet with separate tables by simply using ngpsql ExecuteScalar that would even be preferable... Thanks for any suggestion!
NpgsqlDataReader.NextResult()fairly well (I did a rewrite on it a few years back) andNpgsqlDataAdapter.Fill()should call into that, but that code I don't know well. It could be thatNpgsqlDataAdapter.Fill()handlesNpgsqlDataReader.NextResult()incorrectly, and that this is a bug.