Is there any equivalent from MSSQL to PostgreSQL to return a select statement (which result could be from various tables)? In MSSQL it would be like this:
CREATE PROCEDURE MyProc
AS
BEGIN
SELECT * FROM MyTable
END
MyTable can be any table in MSSQL but in PostgreSQL I have to define from which table I want to return. Like this:
CREATE FUNCTION MyFunction ()
RETURNS setof "MyTable" AS $$
BEGIN
RETURN QUERY SELECT * FROM "MyTable"
END;
$$ LANGUAGE plpgsql;
But what I want to do is return the result from a table which is passed by a param (of course my procedure is more complex and my intention why to do that is not that simple, this is only an abstract).