473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

max sequence value --- how?

aj
DB2 LUW 8.1 fixpak 14
Linux Red Hat AS

I'm trying to get the maximum value of a sequence. Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;

Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?

Note that I'm on DB2 LUW 8.1 fixpak 14. There's apparently some
sequence highwater column in v9, but I don't think I have it.

tia

aj
Jul 22 '08 #1
7 8831
On Jul 22, 1:19 pm, aj <ron...@mcdonalds.comwrote:
DB2 LUW 8.1 fixpak 14
Linux Red Hat AS

I'm trying to get the maximum value of a sequence. Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;

Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?

Note that I'm on DB2 LUW 8.1 fixpak 14. There's apparently some
sequence highwater column in v9, but I don't think I have it.

tia

aj
You can see the next value (that would have been assigned), which is
presumably one more than the present "maximum value" by running the
following:

VALUES NEXTVAL FOR <YOUR_SEQ_SCHEMA.YOUR_SEQ_NAME>;

--Jeff
Jul 22 '08 #2
aj wrote:
DB2 LUW 8.1 fixpak 14
Linux Red Hat AS

I'm trying to get the maximum value of a sequence. Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;

Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?

Note that I'm on DB2 LUW 8.1 fixpak 14. There's apparently some
sequence highwater column in v9, but I don't think I have it.

tia

aj
SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE
If you don't have it on your version look in SYSIBM.SEQUENCES

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 23 '08 #3
aj
Serge: thx for reply.

There is no SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE,
and SYSIBM.SEQUENCES does not exist....???

Any other ideas?
aj
Serge Rielau wrote:
aj wrote:
>DB2 LUW 8.1 fixpak 14
Linux Red Hat AS

I'm trying to get the maximum value of a sequence. Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;

Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?

Note that I'm on DB2 LUW 8.1 fixpak 14. There's apparently some
sequence highwater column in v9, but I don't think I have it.

tia

aj
SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE
If you don't have it on your version look in SYSIBM.SEQUENCES

Cheers
Serge

Jul 23 '08 #4
On Jul 23, 8:09*am, aj <ron...@mcdonalds.comwrote:
Serge: *thx for reply.

There is no SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE,
and SYSIBM.SEQUENCES does not exist....???

Any other ideas?
aj

Serge Rielau wrote:
aj wrote:
DB2 LUW 8.1 fixpak 14
Linux Red Hat AS
I'm trying to get the maximum value of a sequence. *Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;
Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?
Note that I'm on DB2 LUW 8.1 fixpak 14. *There's apparently some
sequence highwater column in v9, but I don't think I have it.
tia
aj
SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE
If you don't have it on your version look in SYSIBM.SEQUENCES
Cheers
Serge- Hide quoted text -

- Show quoted text -
Try SYSIBM.SYSSEQUENCES

/T
Jul 23 '08 #5
aj
This is just what I needed. Thanks Tomas.

Tomas wrote:
On Jul 23, 8:09 am, aj <ron...@mcdonalds.comwrote:
>Serge: thx for reply.

There is no SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE,
and SYSIBM.SEQUENCES does not exist....???

Any other ideas?
aj

Serge Rielau wrote:
>>aj wrote:
DB2 LUW 8.1 fixpak 14
Linux Red Hat AS
I'm trying to get the maximum value of a sequence. Because of the way
the sequence is used (on several tables comprising a fat view), its too
expensive to do the usual
select max(<col>) from <view;
Is there some way for the system catalogs or some trick to get me the
maximum value of the sequence?
Note that I'm on DB2 LUW 8.1 fixpak 14. There's apparently some
sequence highwater column in v9, but I don't think I have it.
tia
aj
SYSCAT.SEQUENCES.NEXTCACHFIRSTVALUE
If you don't have it on your version look in SYSIBM.SEQUENCES
Cheers
Serge- Hide quoted text -
- Show quoted text -

Try SYSIBM.SYSSEQUENCES

/T
Jul 23 '08 #6
Sorry.. sleep deprived.
Have been standing on the Newark runway half of last night :-(

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 23 '08 #7
aj
No problem Serge - I appreciate all the help you provide. :)
Long layovers are no fun...

Serge Rielau wrote:
Sorry.. sleep deprived.
Have been standing on the Newark runway half of last night :-(

Cheers
Serge
Jul 24 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
36741
by: Ken1 | last post by:
I am going to drop a primary key from one column and create a new column to be used as primary key in an existing database. The old column was a date column which someone earlier though was a good...
10
2576
by: Anthony Best | last post by:
I'm working on an idea that uses sequences. I'm going to create a table like this: id serial, sequence int, keyword varchar(32), text text for every keyword there will be a uniq sequence...
4
8147
by: j | last post by:
In a footnote in the c99 standard the following is labeled as undefined: a = i; And in the second clause of section 6.5 the following is stated: "Between the previous and next sequence...
53
4003
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
7
2054
by: akarl | last post by:
Hi all, Why do I get a warning from gcc with the following program? $ cat test.c #include <stdio.h> int f(int n) { return n;
1
2182
by: Marek Lewczuk | last post by:
Hello, I would like to ask if my problem with sequence is a proper behavior or this is a bug (probably not)... I have a table: CREATE TABLE "testtable" ( "serialfield" SERIAL,...
9
2489
by: John Smith | last post by:
I've been playing with splint, which returns the following warning for the code below: statlib.c: (in function log_norm_pdf) statlib.c(1054,31): Expression has undefined behavior (left operand...
1
3013
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the...
7
17341
by: Rahul B | last post by:
Hi, If i do a "Select nextval for <seq_namefrom sysibm.sysdummy1", it increases the values of nextval by1. How can i find out the nextval of a sequence without actually increasing the value....
5
1789
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
Hi, I have a question about the execution sequence of the postfix increment operator with respect to a function call. void foo(int type, int*& data); int* sequence;
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.