Home » SQL & PL/SQL » SQL & PL/SQL » Change into capital letters?
Change into capital letters? [message #263752] Thu, 30 August 2007 23:39 Go to next message
tondapi
Messages: 99
Registered: August 2007
Location: usa
Member
Hi


Iam new to Oracle,my questions is

example: abcd are in small letters, but user want to see first 2 letters are capitals(i.e..ABcd)like that.A ny one can help me ,which function is used for this one?

Re: Change into capital letters? [message #263759 is a reply to message #263752] Thu, 30 August 2007 23:55 Go to previous messageGo to next message
thani_oracle
Messages: 44
Registered: August 2007
Location: Bangalore
Member

SQL> select substr(initcap('ram'),1,1)||initcap(substr('ram',2)) from dual;

SUB
---
RAm


SQL> select substr(initcap(ename),1,1)||initcap(substr(ename,2)) from emp;

SUBSTR(INI
----------
SMith
ALlen
WArd
JOnes
MArtin
BLake
CLark
SCott
KIng
TUrner
ADams

SUBSTR(INI
----------
JAmes
FOrd
MIller

14 rows selected.

Thanks and Regards,
Thani....
Re: Change into capital letters? [message #263764 is a reply to message #263759] Fri, 31 August 2007 00:08 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Although your solution works, it is (in my opinion) less intuitive then using upper and lower:

SQL> select upper(substr(ename, 1, 2))||lower(substr(ename, 3))
  2  from   emp;

UPPER(SUBS
----------
SMith
ALlen
WArd
JOnes
MArtin
BLake
CLark
SCott
KIng
TUrner
ADams
JAmes
FOrd
MIller

14 rows selected.
Re: Change into capital letters? [message #264127 is a reply to message #263752] Sat, 01 September 2007 00:07 Go to previous messageGo to next message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
As his concern is only first 2 character so the remaining character should be unchange

select upper(substr(ename, 1, 2))||substr(ename, 3)
from emp;
Re: Change into capital letters? [message #264159 is a reply to message #264127] Sat, 01 September 2007 03:46 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
@muzahidul islam, Xerox machine has broken in our office. Are you interested in replacing its position? I can see you are quite good in copying others's answers, so I thought that you might broaden the business and become an all-purpose copywriter.
Re: Change into capital letters? [message #264246 is a reply to message #263752] Sun, 02 September 2007 06:14 Go to previous message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
frank query were
Quote:

select upper(substr(ename, 1, 2))||lower(substr(ename, 3))
from emp;



And my query were
Quote:

select upper(substr(ename, 1, 2))||substr(ename, 3)
from emp;



So diff is frank used lower function and i did not. Please try to understand what i wanted to mentioned.
If there value aabDe the
frank output will be
AAbde
and my output will be
AAdDe. That is the difference

[Updated on: Sun, 02 September 2007 06:14]

Report message to a moderator

Previous Topic: Decode function with AND & OR condition
Next Topic: Need help on hirerchy grouping
Goto Forum:
  


Current Time: Sat Dec 10 03:30:07 CST 2016

Total time taken to generate the page: 0.04628 seconds