hello,
Is there a function that I can get type id from type name, such as from 'text' to 25, 'int' to 23. 
thanks in advance.
Jinqiang Han





Tue, 24 Dec 2002 10:49:1 +0800
"Jinqiang Han" <postgresql@db.pku.edu.cn>
about data type id 
Hi Jinqiang,

Try:  SELECT oid FROM pg_type WHERE typname='text';

You can always make that into a function.

Chris

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org 
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Jinqiang Han
> Sent: Tuesday, 24 December 2002 10:00 AM
> To: pgsql-hackers@postgresql.org
> Subject: [HACKERS] about data type id 
> 
> 
> hello,
> Is there a function that I can get type id from type name, such 
> as from 'text' to 25, 'int' to 23. 
> thanks in advance.
> Jinqiang Han
> 
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 


Tue, 24 Dec 2002 11:07:44 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Re: about data type id 
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Try:  SELECT oid FROM pg_type WHERE typname='text';

Another possibility (as of 7.3) is

regression=# select 'int4'::regtype::oid;
 oid
-----
  23
(1 row)

The regtype converter has the advantage that it will recognize any
typename construct understood by the parser, for example

regression=# select 'character varying'::regtype::oid;
 oid
------
 1043
(1 row)

Also, regtype will do the right thing in the presence of schema-related
ambiguities (eg, 'a.foo' and 'b.foo' may both exist in the catalog,
but if only b is in your search path, 'foo' should mean 'b.foo').

			regards, tom lane

Tue, 24 Dec 2002 00:53:43 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: about data type id 