0
下面是一個函數,它有一個查詢,轉換成PostgreSQL動態查詢
現在我想轉換成動態查詢。我想要一個表名參數,以便查詢從多個表中返回數據。
請幫助我在這我在PostgreSQL新,感謝提前!
create or replace function GetEmployees()
returns setof weather as
'select * from weather;'
language 'sql';
您應該始終參考文檔。相信我,這是程序員最好的朋友。 http://www.postgresql.org/docs/current/static/sql-createfunction.html –
Anu,這是一個後續http://stackoverflow.com/questions/16937848/convert-sql-server- stored-procedure-into-postgresql-stored-procedure? –
如果你想傳遞表名,你不能輕易地將它作爲「返回setof」函數,因爲傳遞的表名可能與「weather」表有完全不同的結構。 –