View previous topic :: View next topic |
Author |
Message |
sri50131 Beginner
Joined: 07 Oct 2004 Posts: 38 Topics: 15
|
Posted: Fri Jul 08, 2005 4:10 pm Post subject: Capitalize the First Alphabet like sentence and update(DB2) |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Jul 09, 2005 5:17 am Post subject: |
|
|
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 |
|
 |
sri50131 Beginner
Joined: 07 Oct 2004 Posts: 38 Topics: 15
|
Posted: Sat Jul 09, 2005 10:36 am Post subject: |
|
|
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 |
|
 |
bauer Intermediate
Joined: 10 Oct 2003 Posts: 317 Topics: 50 Location: Germany
|
Posted: Mon Jul 11, 2005 8:50 am Post subject: |
|
|
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 |
|
 |
|
|