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 is the advantage of nosql?

0 Answers  


How to take user input in pl sql?

0 Answers  


Write a sql query to get the third highest salary of an employee from employee_table?

0 Answers  


How to create an array in pl/sql?

0 Answers  


what is bulk bind

4 Answers   TCS,






What are database links used for?

0 Answers  


What is dml statement?

0 Answers  


How can you load multi line records? : aql loader

0 Answers  


What are sql data types?

0 Answers  


Can we use join in subquery?

0 Answers  


sql query to get zero records from a table having n no of records

8 Answers   CTS,


There is a sequence with min value 100. I want to alter this sequence to min value as 101. If the table has already data in the sequence column as 100,101,102... Is it possible to do so ?

4 Answers   IBM,


Categories