Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initcap function

Status
Not open for further replies.

PatelRam

Programmer
Aug 20, 2003
87
US
In Oracle we have initcap function

What is equivalent in db2...???
 
Table a:

Name
====
john smith
peter sam

Oracle Sql: Select initcap(name) from a
Output :

Name
====
John Smith
Peter Sam

It will make upper case for 1st character of the all the word in a column



 
MC's solution will make the whole column upper case. Because you need to change the letter of the 2nd name, which can appear anywhere in the string, I don't think it can be done in SQL. You will need to do this programatically outside of SQL. Call the routine as a UDF as Sathyaram suggests.
 
Visit the excellent IBM DB2 DeveloperDomain site, there is link to porting to DB2 with migration info.
Among these, you'll find a UDFMigration package which includes the code to recreate some 30 or so Oracle functions, the InitCap is one of these.

It works great and accepts any string, special characters and so on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top