How to convert lowercase letters to uppercase and uppercase letters to lowercase in a string. (ex, AbcdEfG should convert as aBCDeFg)

Answers were Sorted based on User's Feedback



How to convert lowercase letters to uppercase and uppercase letters to lowercase in a string. (ex, A..

Answer / agrawal_vivek

easiest way is to use the condition-

for(i=0;s[i]!='';i++)
{
if(s[i]>=65 && s[i]<=90) //Caps ASCII-65-90(60+32=97-----90+32=122)
s[i]=s[i]+32;

if(s[i]>=97 && s[i]<=122) // Small ASCII-97-122(97-32=65-----122-32=90)
s[i]=s[i]-32;
}

Is This Answer Correct ?    3 Yes 1 No

How to convert lowercase letters to uppercase and uppercase letters to lowercase in a string. (ex, A..

Answer / kunal

SELECT listagg(newstr) within GROUP (
ORDER BY rm)
FROM
(SELECT
CASE
WHEN SUBSTR('AbcdEfG',level,1)=upper(SUBSTR('AbcdEfG',level,1))
THEN lower(SUBSTR('AbcdEfG',level,1))
ELSE upper(SUBSTR('AbcdEfG',level,1))
END newstr,
rownum rm
FROM dual
CONNECT BY level <=LENGTH('AbcdEfG')
)

Is This Answer Correct ?    2 Yes 0 No

How to convert lowercase letters to uppercase and uppercase letters to lowercase in a string. (ex, A..

Answer / debashis mohanty

Select 'AbcdEfG',LOWER(SUBSTR('AbcdEfG',1,1))||UPPER(SUBSTR('AbcdEfG',2,3))||LOWER(SUBSTR('AbcdEfG',5,1))||UPPER(SUBSTR('AbcdEfG',6,1))||LOWER(SUBSTR('AbcdEfG',7,1)) From Dual

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

What are wait events. Describe the wait event tables.

1 Answers   CTS,


What steps server process has to take to execute an update statement?

0 Answers  


What is the size of partition table?

0 Answers  


Differentiate between pl/sql and sql?

0 Answers  


Can I learn sql in a week?

0 Answers  






What is difference between procedure and trigger?

0 Answers  


What are the types of queries in sql?

0 Answers  


I have 2 Databases. How can create a table in particular database? How can i know the list of tables presented each database?( in oracle 10g)

5 Answers   Relq,


What is the difference between sql and mysql?

0 Answers  


Explain the advantages and disadvantages of stored procedure?

0 Answers  


How does pl sql work?

0 Answers  


How does rowid help in running a query faster?

0 Answers  


Categories