MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Capitalize the First Alphabet like sentence and update(DB2)

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
sri50131
Beginner


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Fri Jul 08, 2005 4:10 pm    Post subject: Capitalize the First Alphabet like sentence and update(DB2) Reply with quote

Hello,

I am trying to update a column, T_ALT_DESC of PASTMSTR table which has data in Upper Case. I need to convert the data into sentence case. For example,
T_ALT_DESC = ELECTRA GLIDE CLASSIC FLHTC (SOLID) should be

T_ALT_DESC = Electra Glide Classic Flhtc (Solid).

T_ALT_DESC has several other values which need to be converted.

Is it possible with DB2 Update Clause.

Thanks
Sri
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jul 09, 2005 5:17 am    Post subject: Reply with quote

Sri50131,

It can be done in sql but it would be real ugly using atleast 3 scalar functions. Since it is an update I suggest doing it programatically.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sri50131
Beginner


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Sat Jul 09, 2005 10:36 am    Post subject: Reply with quote

kolusu,

I do not have time to do it programatically 'coz we are going live soon. This would be one time thing, so, I would really like to do it thru' SQL.

Thanks
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Mon Jul 11, 2005 8:50 am    Post subject: Reply with quote

well,

the general idea may be like this:


Code:

   SELECT
    UCASE (SUBSTR(<my field>,1,1))
 ||
    REPLACE (
    REPLACE (
    REPLACE (
    REPLACE (
         LCASE(SUBSTR(<my field>,2)), ' a',' A')
                                    , ' b',' B')

                                    , ' t',' T')

                                    , ' z',' Z')

      FROM ...


regards,
bauer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group