pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Handling case variatiions on a user defined type?
3+ messages / 2 participants
[nested] [flat]

* Handling case variatiions on a user defined type?
@ 2019-09-15 12:37  stan <stanb@panix.com>
  0 siblings, 1 reply; 3+ messages in thread

From: stan @ 2019-09-15 12:37 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

I have several enumerated types that look like:

CREATE TYPE confidence_level AS ENUM ('HIGH' ,
                                'MEDIUM' ,
								'LOW' ,
							     'WAG');


I have someone creating data for this project in spreadsheets, and then am
importing the data using \copy.

Problem is the data in the spreadsheets is entered in mixed case.

Is there a way that I can use the type itself, to enforce something like a
to_upper(). Or is there a better way to  "human proof" this?

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





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

* Re: Handling case variatiions on a user defined type?
@ 2019-09-15 12:58  Olivier Gautherot <ogautherot@gautherot.net>
  parent: stan <stanb@panix.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Olivier Gautherot @ 2019-09-15 12:58 UTC (permalink / raw)
  To: stan <stanb@panix.com>; +Cc: pgsql-general@lists.postgresql.org

El dom., 15 de septiembre de 2019 09:37, stan <stanb@panix.com> escribió:

> I have several enumerated types that look like:
>
> CREATE TYPE confidence_level AS ENUM ('HIGH' ,
>                                 'MEDIUM' ,
>                                                                 'LOW' ,
>                                                              'WAG');
>
>
> I have someone creating data for this project in spreadsheets, and then am
> importing the data using \copy.
>
> Problem is the data in the spreadsheets is entered in mixed case.
>
> Is there a way that I can use the type itself, to enforce something like a
> to_upper(). Or is there a better way to  "human proof" this?
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
>                                                 -- Benjamin Franklin
>

What about a trigger on INSERT, which would enforce the case?

>

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

* Re: Handling case variatiions on a user defined type?
@ 2019-09-15 13:26  stan <stanb@panix.com>
  parent: Olivier Gautherot <ogautherot@gautherot.net>
  0 siblings, 0 replies; 3+ messages in thread

From: stan @ 2019-09-15 13:26 UTC (permalink / raw)
  To: Olivier Gautherot <ogautherot@gautherot.net>; +Cc: pgsql-general@lists.postgresql.org

On Sun, Sep 15, 2019 at 09:58:45AM -0300, Olivier Gautherot wrote:
> El dom., 15 de septiembre de 2019 09:37, stan <stanb@panix.com> escribi??:
> 
> > I have several enumerated types that look like:
> >
> > CREATE TYPE confidence_level AS ENUM ('HIGH' ,
> >                                 'MEDIUM' ,
> >                                                                 'LOW' ,
> >                                                              'WAG');
> >
> >
> > I have someone creating data for this project in spreadsheets, and then am
> > importing the data using \copy.
> >
> > Problem is the data in the spreadsheets is entered in mixed case.
> >
> > Is there a way that I can use the type itself, to enforce something like a
> > to_upper(). Or is there a better way to  "human proof" this?
> >
> > --
> > "They that would give up essential liberty for temporary safety deserve
> > neither liberty nor safety."
> >                                                 -- Benjamin Franklin
> >
> 
> What about a trigger on INSERT, which would enforce the case?

That sounds like a good idea, thanks.


-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





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


end of thread, other threads:[~2019-09-15 13:26 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-15 12:37 Handling case variatiions on a user defined type? stan <stanb@panix.com>
2019-09-15 12:58 ` Olivier Gautherot <ogautherot@gautherot.net>
2019-09-15 13:26   ` stan <stanb@panix.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