Обсуждение: ORDER BY in sql functions thows compile error

Поиск
Список
Период
Сортировка

ORDER BY in sql functions thows compile error

От
"K. Ari Krupnikov"
Дата:
Is it legal to have an ORDER BY clause in a SELECT statement inside an
SQL function?

This works fine:

CREATE    FUNCTION getChildNodes (INT)    RETURNS setof INT
AS '
    SELECT    child_node_id
    FROM    t_arch
    WHERE    parent_node_id = $1;
' LANGUAGE 'sql';

But this prints an error:

CREATE    FUNCTION getChildNodes (INT)    RETURNS setof INT
AS '
    SELECT    child_node_id
    FROM    t_arch
    WHERE    parent_node_id = $1
    ORDER BY child_ord_no;
' LANGUAGE 'sql';

This is the error message:
function declared to return int4 returns multiple values in final
retrieve

I'm using Postges 7.0.2

--
K. Ari Krupnikov

DBDOM - bridging XML and relational databases
http://www.iter.co.il