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

can i give user defined exception in a package

2 Answers  


How do you determine the current isolation level? : Transact sql

0 Answers  


Table Order_Name has a column Order_Date which gives the date & Time at which the order is passed.Find the table to write a query to find out the latest order.

5 Answers   Thomson,


What type of database is sql?

0 Answers  


what is overloading procedure or overloading function ?

3 Answers   Genpact,






Explain aggregate functions are available there in sql?

0 Answers  


What is pl sql in oracle?

0 Answers  


What is delimiter in pl sql?

0 Answers  


How to connect a sql*plus session to an oracle server?

0 Answers  


How do we accept inputs from user during runtime?

0 Answers  


i want run a sql query query? which phases are run in a back ground? pls tell me the answer

1 Answers  


tell me about various levels of constraint. : Sql dba

0 Answers  


Categories