× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



David,

There's a trade off between "sequential-ness" and performance,
particularly with multiple jobs using the same sequence.

If you want a strict sequence between multiple jobs, you have to
specify ORDER and NO CACHE. But you'll pay a performance price.

If all you really need is a surrogate key shared between tables, then
the defaults of NO ORDER and CACHE 20 provide the best performance.

HTH,
Charles


On Wed, Nov 25, 2009 at 2:07 PM, David Gibbs <david@xxxxxxxxxxxx> wrote:
Folks:

I'm having a bit of a struggle understanding the SQL Sequence business cases.

I understand the conceptual idea behind SQL Sequences ... but the behavior I'm observing in testing is kind of baffling me.

In interactive SQL (no commitment control), I created a SQL sequence in a schema starting at 1 with a cache value of 10.

I then run the following statement:
select (next value for TESTSEQ1) from sysibm/sysdummy1

I get a result of '1'.

If I run the same SQL statement again, I get the result '2'.

However, if I start interactive SQL in another job, and run the same statement I get a value of '11'.

 From what I understand about SQL Sequences, you're supposed to use it to get a sequential number from SQL on an select, insert, or update statement.

What I'm not understanding is why the 'sequential' number isn't so sequential ... and very gappy.

I do know that I could use the no cache option to disable caching ... but I'm just trying to understand the business cases for the sequence concept.

Thanks!

david

--
IBM i on Power Systems - For when you can't afford to be out of business
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.