473,770 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gaps in a sequence number

Hi there,

I was wondering if anyone could help with this problem.

I have a table with about 250,000 rows that relate to files that have
been processed elsewhere in our business. Each file has a sequence
number as part of the file name that goes from 0000 to 9999 then back
to 0000.

I want to output a list to tell me the missing entries in that list
(or the entries directly before and after the gaps) so i can go and
investigate what has happened to those files.

Sorry if this seems like a pointless problem but I really need an
answer ASAP.

Many thanks,

Rob.
Nov 13 '05 #1
3 5774
Please give us some examples of file names and explain what you mean by
"...then back to 0000."

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com

"Robert McGregor" <rm*******@fire net.uk.com> wrote in message
news:8d******** **************@ posting.google. com...
Hi there,

I was wondering if anyone could help with this problem.

I have a table with about 250,000 rows that relate to files that have
been processed elsewhere in our business. Each file has a sequence
number as part of the file name that goes from 0000 to 9999 then back
to 0000.

I want to output a list to tell me the missing entries in that list
(or the entries directly before and after the gaps) so i can go and
investigate what has happened to those files.

Sorry if this seems like a pointless problem but I really need an
answer ASAP.

Many thanks,

Rob.

Nov 13 '05 #2
I assume it means count off 0 to 9999 and then restart at zero... kind
of a bad idea if you're going to have more than 10K records, though...
Umm... find the gaps... how about create a numberlist table and
populate it with some code...

Something like this:

Create Sequences code:
Option Compare Database
Option Explicit

Public Sub PopulateSequenc es(ByVal lngRecsToAdd As Long)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim lngCounter As Long

Set db = CurrentDb
' didn't like dbappendonly... huh? (wouldn't compile)
Set rs = db.OpenRecordse t("tblSequences ", dbOpenTable)
For lngCounter = 1 To lngRecsToAdd
rs.AddNew
rs.Fields("sequ enceNo") = lngCounter
rs.Update
Next lngCounter

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub

Create Find Unmatched Query: ==>returns all the sequences that aren't
"used up" SELECT tblSequences.se quenceNo
FROM tblSequences LEFT JOIN tblApartments ON tblSequences.se quenceNo =
tblApartments.A ptID
WHERE (((tblApartment s.AptID) Is Null));

Checking for gaps where you return lngBeginGap and lngEndGap is a bit
trickier. You have to open the recordset (forwardonly is fine) and
then have a counter increment as you loop through the records. If the
counter and the value of the record's field are not the same, then
there's a gap, so write the last "sequence number" somewhere. Then
increment the counter until it is equal to the next number in the
table/recordset. write that down and continue. Then you could just
write the gaps to another table or something.

Nov 13 '05 #3
My thought was to create a table of numbers from 0 to 9999 and then use an
unmatched query to look for missing numbers. Need to see the file names to
say how to apply that.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
<pi********@hot mail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
I assume it means count off 0 to 9999 and then restart at zero... kind
of a bad idea if you're going to have more than 10K records, though...
Umm... find the gaps... how about create a numberlist table and
populate it with some code...

Something like this:

Create Sequences code:
Option Compare Database
Option Explicit

Public Sub PopulateSequenc es(ByVal lngRecsToAdd As Long)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim lngCounter As Long

Set db = CurrentDb
' didn't like dbappendonly... huh? (wouldn't compile)
Set rs = db.OpenRecordse t("tblSequences ", dbOpenTable)
For lngCounter = 1 To lngRecsToAdd
rs.AddNew
rs.Fields("sequ enceNo") = lngCounter
rs.Update
Next lngCounter

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub

Create Find Unmatched Query: ==>returns all the sequences that aren't
"used up" SELECT tblSequences.se quenceNo
FROM tblSequences LEFT JOIN tblApartments ON tblSequences.se quenceNo =
tblApartments.A ptID
WHERE (((tblApartment s.AptID) Is Null));

Checking for gaps where you return lngBeginGap and lngEndGap is a bit
trickier. You have to open the recordset (forwardonly is fine) and
then have a counter increment as you loop through the records. If the
counter and the value of the record's field are not the same, then
there's a gap, so write the last "sequence number" somewhere. Then
increment the counter until it is equal to the next number in the
table/recordset. write that down and continue. Then you could just
write the gaps to another table or something.

Nov 13 '05 #4

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

Similar topics

2
2526
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has been inserted. The sequence number can only be created after we go to the second line. Please see the trigger below. Is there anyway we could create a trigger that could create the sequence number as soon as we enter a value? It should be...
4
7732
by: Kamran K | last post by:
Hello I have created a client server application using C#. Existing application is using random number on client side to generate sequence numbers that are then assigned to transactions. This results in duplicate sequence numbers across multiple users. Solution to this problem is to generate the sequence number on the server. Since this is not an ASP app, I cannot use Global.asax Application object to keep track of begin application.
12
3082
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ------- batch1 1 batch1 2
5
28620
by: tojigneshshah | last post by:
Hi, How to restart sequence number once the data is imported/loaded into the tables? Please advise. regards Jignesh
1
2527
by: ddice | last post by:
I need to update and then read a sequence number, but I think its failing when there are many users updating at the same time. Here's what I'm doing update datatable set nextnr = nextnr+1 where somecondition select nextnr from datatable where somecondition I don't think I always get the correct sequence number. There must be a better way to do this. Thanks
0
2105
by: Mikelowe | last post by:
Would like to know is there an automated way to copy the maxvalue of sequence number from db2 production to db2 test. When we copy data from our production that uses a sequence number value as its unique key into test, we get problems doing inserts in test unless we also manually update the test.sequence to be equal to or greater than the production.sequence number. Can this manual process be automated by a utility or something simple? ...
21
1606
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index) within the sorted collection) Additional info: insert() returns a pair<Tand find() returns an iterator. Using any of these two objects is it possible to get the sequence number of the item these objects point to? After the insert() or find()...
1
1790
by: kama | last post by:
I want to create sequence number for repeating data values. This sequence number will re-start from 1 for each new value. Example as below:- Amount sequence_number 200 1 200 2 100 1 500 1 500 2 500 3 500 4
2
2398
by: XML fellow | last post by:
hi, i would like to define a unique key in the XSD, and once generating a default XML out of it (using XSD2INST tool), the XML will automaticaly be populated with a unique sequence number. similar to defining a sequence number in DB. can anyone advise how to do that? thanks :-)
0
9602
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5326
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
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.