Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> help it

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: help it
 Garlapati  Posted: Mar 04, 2008 04:44:00 AM

 Total Post: 30
 Joined: Apr, 2007






 i have a table with two columns
1) name
2) sex

i am little bit confuse plz give me soultion
i want to update males with female
female with male
after updation
male row should be female
and female row should be male
i want to exchange the male with female
and females with males

viseversa

thanq in dvance

 Murtuja
Posted: Mar 04, 2008 05:26:10 AM  

 Total Post: 857
 Joined: Jan, 2006






 
You have to issue update statement three time to achive that.

update table_a
set sex='M_Temp'
where sex='F'


update table_a
set sex='F'
where sex='M'


update table_a
set sex='M'
where sex='M_Temp'



 Garlapati
Posted: Mar 05, 2008 02:40:30 AM  

 Total Post: 30
 Joined: Apr, 2007






 
Thanq, but is there any sql statement or pl/sql subprogramme for this
if plz forward it ..

thanq

 sad
Posted: Mar 05, 2008 07:17:32 AM  

 Total Post: 24
 Joined: Feb, 2008






 
Hi Murtuja,

update table_a
set sex='F'
where sex='M'

I think this command wont work.. bcoz we cant use the same column name in both 'set' and 'where' condition

 jayesh
Posted: Mar 05, 2008 09:18:19 AM  

 Total Post: 60
 Joined: Jan, 2008






 
UPDATE table_name
SET DECODE(GENDER,'M','F','F','M');
just try it.

 jayesh
Posted: Mar 07, 2008 09:55:28 AM  

 Total Post: 60
 Joined: Jan, 2008






 
sorry the right statement for this kinda update is
update table_name
set column_name= decode(column_name,'m','f','f','m');


 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik387
  Vinoth Kumar379
  Gopu Gopi350
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software