Нужна помощь - переписать процедуру написанную на Firebird - на postgresql
CREATE PROCEDURE GET_CODGROUPS ( DOMAIN_ID INTEGER, LEVEL_START INTEGER) RETURNS ( OUT_DOMAIN_ID INTEGER, RELATIVE_ID INTEGER, OUT_LEVEL INTEGER) AS BEGIN IF ( DOMAIN_ID IS NOT NULL ) THEN BEGIN RELATIVE_ID = DOMAIN_ID; OUT_DOMAIN_ID = DOMAIN_ID; OUT_LEVEL = LEVEL_START; SELECT ID FROM BINARY_TREE WHERE ID = :RELATIVE_ID INTO :RELATIVE_ID; SUSPEND; END FOR SELECT CT.ID FROM BINARY_TREE CT WHERE CT.ID_PARENT = <img class="ccfilter smileys" src="https://pgdocs.ru/sites/all/modules/ccfilter/smileys/ag.gif" alt=":D" title=":D" />OMAIN_ID ORDER BY CT.ID INTO :RELATIVE_ID DO BEGIN FOR SELECT RELATIVE_ID, OUT_LEVEL FROM GET_CODGROUPS(:RELATIVE_ID, :LEVEL_START + 1) INTO :RELATIVE_ID, :OUT_LEVEL DO SUSPEND; END END^ SET TERM ; ^ //INITIAL PARAMETERS EXAMPLE DOMAIN_ID = 1, LEVEL_START = 0 //SELECT * FROM GET_CODGROUPS(1,0);