IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query on DB2 ....


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 8:21 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed Apr 10, 2013 8:49 pm
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

Global Moderator


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

PostPosted: Wed Apr 10, 2013 8:51 pm
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

Moderator Emeritus


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

PostPosted: Wed Apr 10, 2013 9:51 pm
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: 184
Location: Coimbatore

PostPosted: Wed Apr 10, 2013 9:54 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Apr 10, 2013 9:56 pm
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

Moderator Emeritus


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

PostPosted: Wed Apr 10, 2013 10:10 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top