Code:
CREATE OR REPLACE FUNCTION connectby(text, text, text, text, text, integer)
RETURNS SETOF record AS
'$libdir/tablefunc', 'connectby_text_serial'
LANGUAGE 'c' STABLE STRICT
COST 1
ROWS 1000;
ALTER FUNCTION connectby(text, text, text, text, text, integer) OWNER TO postgres;
Ne znam koju verziju PG koristis, ako je manja od 8.2 najverovatnije ce ti javljati gresku
na COST i ROWS, mozes da izbacis to.
Pozivas ovako:
Code:
SELECT ta.id,ta.parrent,ta.opis FROM tabela ta,
CONNECTBY('tabela', 'id','parrent', 'opis', '0', 0) as t(ide int, p_id int, lv int, pos int)
WHERE ta.id = ide
"Ne menjaj nesto sto te sasvim dobro sluzi, ne trazi leba preko pogace" - Aleksandar Andrijevic