order by, within a plpgsql fx

From: <david(dot)sahagian(at)emc(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: order by, within a plpgsql fx
Date: 2011-12-02 15:04:37
Message-ID: F3CBFBA88397EA498B22A05FFA9EC49D5B9F2E51@MX22A.corp.emc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Please consider this plpgsql function:
= = = = = = = = = =
CREATE Or Replace FUNCTION fx_order_by ( )
RETURNS table( last_name text, first_name )
AS $eofx$
DECLARE
--
BEGIN

Return Query
select
lname, fname
from
my_table
order by
lname ASC
;

END;
$eofx$ LANGUAGE plpgsql;
= = = = = = = = = =

So, is this select statement's result set guaranteed to be ordered as specified by the [order by] coded within the function body ?
= = = = = = = = = =
select last_name, first_name from fx_order_by() ;
= = = = = = = = = =

Or, must I code another [order by] to be sure ?
= = = = = = = = = =
select last_name, first_name from fx_order_by() order by last_name ;
= = = = = = = = = =

Also, is the answer the same for a "sql" function ?

Thanks,
-dvs-

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-12-02 15:43:44 Re: order by, within a plpgsql fx
Previous Message Richard Huxton 2011-12-02 14:28:52 Re: sql statements using access frontend