Oliver Elphick wrote:
I tried to use regclass() in a plpgsql function to derive a tablename
from its oid so as to build a command string, but I am unable to use the
value returned because it cannot be cast to anything.  Therefore I will
have to use a complex query on the catalog to do the same work.

This seems overly restrictive.  Would there be a problem in allowing
regclass() to be cast to text?


I agree (I've been frustrated by this myself before), but for a workaround, see the following:


create or replace function any2text(anyelement) returns text as'
begin
 return $1;
end
' language plpgsql;

select any2text(1255::oid::regclass) || ' is the relname in text';
            ?column?
--------------------------------
 pg_proc is the relname in text
(1 row)

HTH,

Joe

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to