Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Update table without cursor

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

New User


Joined: 28 Sep 2012
Posts: 13
Location: holland

PostPosted: Wed Oct 11, 2017 1:06 pm    Post subject: Update table without cursor
Reply with quote

Hello

The example beneath is somewhat simplified.

I have a table called DIM-month, containing information about months. It contains the next columns.

Month-key
Year
Month-number
Month-name

I also have a table DIM-day. It contains the next columns.
Day-key
Date
Month-key
Weekend-indication
Holiday-indication

Now I added two columns to DIM-month.
Number-weekend-days (this is the aggregation for a specific month of number of records in DIM-day where weekend-indication = Y)
Number-holiday-days (this is the aggregation for a specific month of number of records in DIM-day where holiday-indication = Y)

How do I update these two columns for every row, every month in DIM-month without using a cursor (in for instance a Cobol program)?
So in a single SQL?

Thnx
Ron
Back to top
View user's profile Send private message

RahulG31

Active User


Joined: 20 Dec 2014
Posts: 401
Location: USA

PostPosted: Wed Oct 11, 2017 9:25 pm    Post subject: Reply to: Update table without cursor
Reply with quote

Try this:

Code:
Update DIM-month A
Set Number-weekend-days =
(Select Count(*)
 from DIM-day B
 Where A.Month-key = B.Month-key
  and B.Weekend-indication = 'Y'
 );


Similar query can be run for holiday days.

.
Back to top
View user's profile Send private message
Ron Klop

New User


Joined: 28 Sep 2012
Posts: 13
Location: holland

PostPosted: Fri Oct 13, 2017 12:25 am    Post subject: Reply to: Update table without cursor
Reply with quote

Dank
dit werkt
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 189
Location: Maryland

PostPosted: Fri Oct 13, 2017 3:26 am    Post subject: Re: Reply to: Update table without cursor
Reply with quote

Ron Klop wrote:
Dank
dit werkt

"Ich weiss nicht was soll es bedeuten..."?
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 Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Adding a userid to SMTP Security table Yolanda Harvey JCL & VSAM 1 Sun Aug 13, 2017 6:16 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us