Re: [SQL] User defined types

2004-11-25 Thread Tom Lane
Reza Shanbehbazari Mirzaei <[EMAIL PROTECTED]> writes: > I have a user define type called VALID_TIME. It is declared as follows: > CREATE TYPE VALID_TIME AS (t_s TIMESTAMP, t_e TIMESTAMP); > Once I have used this in a table declaration, is it possible to extract > parts of it, for example t

[SQL] User defined types

2004-11-25 Thread Reza Shanbehbazari Mirzaei
Hello: I have a user define type called VALID_TIME. It is declared as follows: CREATE TYPE VALID_TIME AS (t_s TIMESTAMP, t_e TIMESTAMP); Once I have used this in a table declaration, is it possible to extract parts of it, for example to only read t_s or t_e? If so, how do I do this?

Re: [SQL] User defined types -- Social Security number...

2004-06-06 Thread Christopher Browne
In the last exciting episode, "Greg Patnude" <[EMAIL PROTECTED]> wrote: > Thanks Josh -- I understand that there are valid and invalid SSN's -- > similar rules apply to zip codes and area codes... > > I tried this: > > SELECT to_char(123456789, '000-00-'); > which yields 123-45-6789 -- nicely,

Re: [SQL] User defined types -- Social Security number...

2004-03-01 Thread Michael Chaney
On Sun, Feb 29, 2004 at 11:11:31PM -0500, Christopher Browne wrote: > The world rejoiced as [EMAIL PROTECTED] (Michael Chaney) wrote: > > Look, you're thinking way too hard on this. An SSN is a 9-digit number, > > nothing more. There are some 9-digit numbers which aren't valid SSN's, > > and you

Re: [SQL] User defined types -- Social Security number...

2004-03-01 Thread Michael Chaney
On Mon, Mar 01, 2004 at 09:42:48AM -0800, Steve Crawford wrote: > I missed the start of this thread but will chime in with a comment > anyway. > > My rule is to select an appropriate numeric type of data if you will > be doing numeric types of things to it, character types if you will > be doin

Re: [SQL] User defined types -- Social Security number...

2004-03-01 Thread Steve Crawford
On Monday 01 March 2004 8:54 am, Dana Hudes wrote: > I would represent an SSN as numeric(9,0). > an int 32 would work though. > 2**31 is > 9 > > On Sun, 29 Feb 2004, Christopher Browne wrote: > > The world rejoiced as [EMAIL PROTECTED] (Michael Chaney) wrote: > > > Look, you're thinking wa

Re: [SQL] User defined types -- Social Security number...

2004-03-01 Thread Dana Hudes
I would represent an SSN as numeric(9,0). an int 32 would work though. 2**31 is > 9 On Sun, 29 Feb 2004, Christopher Browne wrote: > The world rejoiced as [EMAIL PROTECTED] (Michael Chaney) wrote: > > Look, you're thinking way too hard on this. An SSN is a 9-digit number, > > nothing mor

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Christopher Browne
The world rejoiced as [EMAIL PROTECTED] (Michael Chaney) wrote: > Look, you're thinking way too hard on this. An SSN is a 9-digit number, > nothing more. There are some 9-digit numbers which aren't valid SSN's, > and you might want to get fancy and create a constraint for that. > > Regardless, yo

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Michael Chaney
On Sun, Feb 22, 2004 at 04:45:51PM -0800, Greg Patnude wrote: > Thanks Josh -- I understand that there are valid and invalid SSN's -- > similar rules apply to zip codes and area codes... > > I tried this: > > SELECT to_char(123456789, '000-00-'); > which yields 123-45-6789 -- nicely, I might ad

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Greg Patnude
Thanks Josh -- I understand that there are valid and invalid SSN's -- similar rules apply to zip codes and area codes... I tried this: SELECT to_char(123456789, '000-00-'); which yields 123-45-6789 -- nicely, I might add... the trick is getting postgreSQL to do this without having to create

Re: [SQL] User defined types -- Social Security number...

2004-02-28 Thread Bruce Momjian
Josh Berkus wrote: > Greg, > > > Anyone have a good pre-built user-defined type definition for creating / > > maintaining / manipulating a SSN ... where valid chars are in the range > > 000-00- through 999-99-. > > Actually, the range is more narrowly defined than that. I'm not sure of t

Re: [SQL] User defined types -- Social Security number...

2004-02-22 Thread Josh Berkus
Greg, > Anyone have a good pre-built user-defined type definition for creating / > maintaining / manipulating a SSN ... where valid chars are in the range > 000-00- through 999-99-. Actually, the range is more narrowly defined than that. I'm not sure of the exact rules, but you will nev

[SQL] User defined types -- Social Security number...

2004-02-20 Thread Greg Patnude
Anyone have a good pre-built user-defined type definition for creating / maintaining / manipulating a SSN ... where valid chars are in the range 000-00- through 999-99-. I imagine that the storage column is probably varchar(11) -- I am looking for a type definition that 1) checks that