Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query Needed

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Wed Dec 28, 2005 10:27 am    Post subject: Query Needed
Reply with quote

Hi All ,

My requirement is like this

Name salary paid
bbbb 10000 y
cccc 12000 y
dddd 13000 n
eeee 14000 y
ffffff 15000 n

This is a db2 table , here i want to change the paid flag from y to n and n to y in a single DB2 Query

thanks in advance
Balaji
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Dec 28, 2005 10:30 am    Post subject: Re: Query Needed
Reply with quote

And what is the primery key for the table ?

Regards,

Priyesh.
Back to top
View user's profile Send private message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Wed Dec 28, 2005 10:34 am    Post subject:
Reply with quote

there a employee id column is foreign key in this table
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Wed Dec 28, 2005 11:34 am    Post subject: Query
Reply with quote

Hi balaji,
V can use a temperory flag in order to change y--n and n--y. but it will take three queries. as like swapping v can do ie., y--a and n--y finally a--n. like that.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Dec 28, 2005 11:34 am    Post subject: Re: Query Needed
Reply with quote

I have yet to run a query for that...meanwhile, Here is discussed exactly what you requested for....Dont know the results...

http://ibmmainframes.com/viewtopic.php?t=7260

Regards,

Priyesh.
Back to top
View user's profile Send private message
nrsmca

New User


Joined: 25 May 2005
Posts: 14

PostPosted: Mon Jan 09, 2006 7:43 pm    Post subject:
Reply with quote

Update empsaltable a
set a.flag =
(Select (case
when (b.flag = 'y') then (n)
else (y)
end) b.flag
from empsaltable b where a.name = b.name);

Please Correct me...!
Back to top
View user's profile Send private message
umed

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Mon Jan 09, 2006 9:10 pm    Post subject: Re: Query Needed
Reply with quote

Hi,
u can use following query

update t1_emp a
set sex=(select distinct(sex) from t1_emp b where b.sex <> a.sex)

Let me know if u have any concerns

Regards,
Umed
Back to top
View user's profile Send private message
ragshere

New User


Joined: 20 Dec 2004
Posts: 70

PostPosted: Tue Jan 10, 2006 3:01 pm    Post subject: see this
Reply with quote

update EMP
set paid =
( case select
when paid='Y' then 'N'
when paid='N' then 'Y'
end
)


Bye
Rags
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us