On Thu, 2009-02-19 at 17:13 -0800, David E. Wheeler wrote:
> CREATE OR REPLACE FUNCTION mytest(NAME, NAME[]) RETURNS setof text AS
> $$
> SELECT quote_ident($2[i])
> FROM generate_series(1, array_upper($2, 1)) AS s(i)
> EXCEPT
> SELECT quote_ident(p.proname)
> FROM pg_catalog.pg_proc p
> JOIN pg_catalog.pg_namespace n
> ON p.pronamespace = n.oid
> AND quote_ident(n.nspname) = quote_ident($1)
> ORDER BY s.i
> $$ LANGUAGE SQL;
>
You can make it work by naming the first quote_ident like
"quote_ident($2[i]) AS foo" and then doing ORDER BY foo.
It seems a little strange to me, too, but I assume that it's SQL
standard behavior.
Regards,Jeff Davis