我有下面定義的遞歸方法:PostgreSQL的:申請查詢返回的功能
with recursive temp(id, s, r, e) as (
select *
from rel
where rel_to_id = <parameter from sql query>
union all
select *
from temp P
inner join relationship C on P.r = C.s
)
,我需要把這種對各行從SQL查詢與遞歸查詢定義的列值返回(標記爲)
我真的不想通過python調用X查詢,這會降低速度,必須有一種方法可以在sql中完成。我試圖在plpgsql中編寫一個函數,但是我無法定義返回類型setof TABLE,並且每次都將它聯合起來。
標記爲?我猜是吧? –
沒有返回類型「setof TABLE」。它可以是「TABLE」或「SETOF」。見[這裏](http://www.postgresql.org/docs/current/static/sql-createfunction.html) –