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
 
Query on DB2 ....

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

Active User


Joined: 14 Sep 2009
Posts: 149
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 8:21 pm    Post subject: Query on DB2 ....
Reply with quote

Hi,
I need a help.
I have several entries in my DB2 table like,
10 STATUS1
10 STATUS2
10 STATUS3
10 STATUS4
I need to read the current entry from the DB2 table. According to my example it is STATUS4, if in this case I need to fetch the previous of that from the table ie) STATUS3 needs to be fetched.
Could you please help me on how this could be done???
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1782
Location: Bloomington, IL

PostPosted: Wed Apr 10, 2013 8:49 pm    Post subject:
Reply with quote

You recognize that "the previous" is undefined (as well as bad English) unless the SELECT includes an ORDER BY clause, yes?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Wed Apr 10, 2013 8:51 pm    Post subject:
Reply with quote

You need to explain the significance of statuses indirectly atleast so someone can assist
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 10, 2013 9:51 pm    Post subject:
Reply with quote

Hello,

How does one know that STATUS4 is "current"?

Do the rows contain a date/time stamp?

What if STATUS3 was deleted and then re-inserted - is this now "current"?
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 149
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 9:54 pm    Post subject:
Reply with quote

Even though I use the SELECT with ORDER BY i could arrange them in an ASC or DSC, but how could I get the last previous exactly from my DB2 table :-(

Also as you asked the significance of status field, using this status field there are going to be some online process and DB2 table updation.

Please let me know if you need any more information...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10355
Location: italy

PostPosted: Wed Apr 10, 2013 9:56 pm    Post subject: Reply to: Query on DB2 ....
Reply with quote

Quote:
Please let me know if you need any more information...


describe the logic to determine the current entry
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 10, 2013 10:10 pm    Post subject:
Reply with quote

Hello,

Quote:
but how could I get the last previous exactly from my DB2 table
I suspect, You will need to include "something" in the design of the table to support "most current".
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 Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 3 Tue Nov 07, 2017 8:34 pm
No new posts Query on XMITIP abdulrafi All Other Mainframe Topics 1 Wed Oct 25, 2017 6:54 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am

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