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

Cursor for generating sequence numbers


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

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jan 11, 2008 1:53 pm
Reply with quote

Hi,

I have two tables T1 & T2 with columns T1_SEQ(integer) and T2_SEQ(integer) respectively

I need a cursor which will give all the numeric values which is not present in T1 and T2.

Code:


T1_SEQ              T2_SEQ
------              ------
1                     4
2                     6
3                     9


Code:

Cursor Output
-------------
5
7
8



I have some alternatives. But I want to know whether it is possible or not.

Thanks,
Arun
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Jan 11, 2008 6:29 pm
Reply with quote

It is not possible. The result set you describe has an infinite number (well up to the largest number an integer type can be) of rows in it. The values an integer can store range from -2,147,483,648 to +2,147,483,647.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jan 11, 2008 9:23 pm
Reply with quote

Hi Steve,

I m sorry for not making it clear. I need only the values till MAX(T2_SEQ).
we are using db2 v7

Thanks,
Arun
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jan 11, 2008 9:29 pm
Reply with quote

?? you want a result set based on rows that are not there?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 11, 2008 9:35 pm
Reply with quote

It could be done for the seq that is in one table but not the other but I'm not sure about a number missing from both tables. It may be possible but the expense may be high.
Back to top
View user's profile Send private message
rashmi.ranjan75

New User


Joined: 20 Feb 2006
Posts: 34

PostPosted: Fri Feb 22, 2008 8:49 pm
Reply with quote

after looking into the example given by you it seems that you want to fetch all the numbers which are

- less than the max number in T2
- not present in any of the tables T1 or T2

correct me if i am wrong...becz requirement is not very clear..
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts Find missing sequence for every key DFSORT/ICETOOL 3
No new posts GDG all in sequence order JCL & VSAM 9
Search our Forums:

Back to Top