Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

initcap function and roman numbers

896976Mar 30 2019 — edited Apr 2 2019

Hello I have some titles in capital letters I want to use the INITCAP function to change it to proper capitalization, the problem is when I have roman numbers

It is displaying like this

subj  number         title            credits

KOR 120               Korean Ii        4

CHI    220D            Chinese Ii    4

KOR 220                  Korean Iii    4

CHI 100                  Chinese I      4

Notice that if the title has two leteers like II it change the second one to  Ii 

The query without the INTCAP function

SELECT

       distinct

      subj_code,

      crse_numb,

       crse_title ,

      credits

      FROM

      test_titles

     

returns

CHI 100 CHINESE I 4

CHI 220D CHINESE II 4

KOR 120 KOREAN II 4

KOR 220 KOREAN III 4

with the INITCAP returns

KOR 120 Korean Ii 4

CHI 220D Chinese Ii 4

KOR 220 Korean Iii 4

CHI 100 Chinese I 4

I need to preserve the Roman value the way it is.

here are the scripts to create the table and insert the values

-Thank you

create table test_titles

         (

           subj_code varchar2(4 char),

           crse_numb varchar2(5 char),

           crse_title varchar2(35),

           credits number(2)

         )

      insert into test_titles

      (subj_code,crse_numb,crse_title,credits) select  'CHI','100','CHINESE I','4' FROM DUAL;

      COMMIT;

      insert into test_titles

      (subj_code,crse_numb,crse_title,credits) select  'CHI','220D','CHINESE II','4' FROM DUAL;

        insert into test_titles

      (subj_code,crse_numb,crse_title,credits)   select  'KOR','120','KOREAN II','4' FROM DUAL;

         insert into test_titles

      (subj_code,crse_numb,crse_title,credits)   select  'KOR','220','KOREAN III','4' FROM DUAL;

Comments
Post Details
Added on Mar 30 2019
11 comments
878 views