Handling case variatiions on a user defined type?

Started by stanover 6 years ago3 messagesgeneral
Jump to latest
#1stan
stanb@panix.com

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

#2Olivier Gautherot
ogautherot@gautherot.net
In reply to: stan (#1)
Re: Handling case variatiions on a user defined type?

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?

Show quoted text
#3stan
stanb@panix.com
In reply to: Olivier Gautherot (#2)
Re: Handling case variatiions on a user defined type?

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