If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Store value for coulmn in lowercase

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-08, 23:32
sundaram sundaram is offline
Registered User
 
Join Date: Mar 2006
Posts: 104
Store value for coulmn in lowercase

Hi

We use DB2 8.2.6 on windows 2000.

Would like to force value of a column in a table to be always stored in lower case. i.e even if some one inserts in mixed case.

Is there a facility in DB2 to do this?


Regards

Harikumar
Reply With Quote
  #2 (permalink)  
Old 01-15-08, 00:39
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You can use 2 triggers (insert after and update after) to do this. Use the lower function to change the value every time a row is inserted or updated.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 01-15-08, 03:00
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
I'd suggest to use a BEFORE trigger and set the value to lowercase before the insert or update is performed.
Reply With Quote
  #4 (permalink)  
Old 01-15-08, 04:09
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Another alternative is to use views and instead-of triggers. Thinking about views, you could also store the data in mixed-case in the table and mask this with a view. Blair Adamache wrote an article about that a while ago.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 01-15-08, 17:24
sundaram sundaram is offline
Registered User
 
Join Date: Mar 2006
Posts: 104
Thanks for the suggestions. We like the idea of masking with views and may implement that

Regards

Harikumar
Reply With Quote
  #6 (permalink)  
Old 01-15-08, 17:51
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I collected a few variations on case-insensitive string operations in DB2 here: http://www.ibm.com/developerworks/db...dm-0712stolze/
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On