pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Check type compatibility
3+ messages / 3 participants
[nested] [flat]

* Check type compatibility
@ 2010-03-06 11:04  Gianvito Pio <pio.gianvito@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Gianvito Pio @ 2010-03-06 11:04 UTC (permalink / raw)
  To: pgsql-sql

Hi all,
is there a way to check if two attribute are type compatible (for 
example integer and serial, integer and integer, character varying and 
text, etc..)?

Example:
IF (compatible (table1.att1, table2.att2)) THEN
         ...
ELSE
         ...
END IF;

Thanks




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Check type compatibility
@ 2010-03-06 11:22  Nilesh Govindarajan <lists@itech7.com>
  parent: Gianvito Pio <pio.gianvito@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Nilesh Govindarajan @ 2010-03-06 11:22 UTC (permalink / raw)
  To: Gianvito Pio <pio.gianvito@gmail.com>; +Cc: pgsql-sql

On Sat, Mar 6, 2010 at 4:34 PM, Gianvito Pio <pio.gianvito@gmail.com> wrote:

> Hi all,
> is there a way to check if two attribute are type compatible (for example
> integer and serial, integer and integer, character varying and text, etc..)?
>
> Example:
> IF (compatible (table1.att1, table2.att2)) THEN
>        ...
> ELSE
>        ...
> END IF;
>
> Thanks
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

Explain in more detail.

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Check type compatibility
@ 2010-03-06 13:21  Little, Douglas <DOUGLAS.LITTLE@orbitz.com>
  parent: Gianvito Pio <pio.gianvito@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Little, Douglas @ 2010-03-06 13:21 UTC (permalink / raw)
  To: Gianvito Pio <pio.gianvito@gmail.com>; pgsql-sql

Hello,
I believe types are compatible if they can be cast automatically.
The pg_cast table record all possible casts between types.   If it castcontext is 'a' then I belive it's an automatic conversion which is what I think you want.  'i' implicit means that cast is possible, but must be explicitly cast. 

I suspect that you'll need to write a function that consults the table for the type pair. 

Cheers
Doug



-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Gianvito Pio
Sent: Saturday, March 06, 2010 5:04 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Check type compatibility

Hi all,
is there a way to check if two attribute are type compatible (for 
example integer and serial, integer and integer, character varying and 
text, etc..)?

Example:
IF (compatible (table1.att1, table2.att2)) THEN
         ...
ELSE
         ...
END IF;

Thanks


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-03-06 13:21 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-03-06 11:04 Check type compatibility Gianvito Pio <pio.gianvito@gmail.com>
2010-03-06 11:22 ` Nilesh Govindarajan <lists@itech7.com>
2010-03-06 13:21 ` Little, Douglas <DOUGLAS.LITTLE@orbitz.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox