misterstick
Programmer
i'd like to be able to have an arbitrary number of
sequences against a single table.
i realise that general algorithm questions like this aren't
really what this forum is about, but i thought someone
might have come across this problem before, or could find
or have found a solution somewhere.
some background.
we use a batching algorithm to import transactions.
users create a batch of posting records, update the batch
and the process validates and updates the data from the
postings (external to the system) into transactions
(internal) adding it into all necessary summary tables at
the same time.
each batch of postings is described in a header record
called, surprisingly BATCH_HEAD. the BATCH_HEAD records
have an arbitrary number as their unique identifier
BATCH_NO. for auditing purposes these BATCH_NOs must be
sequential, there must be no gaps.
in days gone by when we had direct files (CISAM, etc) there
was no problem with this, just store the last number in a
single record key file, and lock and update it as necessary.
in oracle, we've has to use sequences because locking
doesn't work. this works well enough: the write of a
BATCH_HEAD record is done close enough to the number
getting pulled off the sequence that missing numbers are so
far not an issue.
time passes, specs change.
the system has been updated so that it is multi-company.
the number of companies is arbitrary and user-defined.
the BATCH_HEAD table is now keyed by company and batch_no.
the batch numbers must still be sequential and gapless, but
now within company: company 1 gets its own set of batches
within the table numbered 1 to m, and if company 2 exists
it does too, numbered 1 to n.
in CISAM the logic doesn't change much, you just add a
record to the key table for each company and retrieve
records by company. the lock, read, update, unlock
processing works just as well.
in oracle, however, things aren't so simple. i can think of
several ways to do this. each, however, requires a giant
mess of PL/SQL.
although excited by the prospect of writing densely
impenetrable logic i'd really rather try and keep things as
simple as possible.
anybody have any ideas?
many thanks,
mr s. <
sequences against a single table.
i realise that general algorithm questions like this aren't
really what this forum is about, but i thought someone
might have come across this problem before, or could find
or have found a solution somewhere.
some background.
we use a batching algorithm to import transactions.
users create a batch of posting records, update the batch
and the process validates and updates the data from the
postings (external to the system) into transactions
(internal) adding it into all necessary summary tables at
the same time.
each batch of postings is described in a header record
called, surprisingly BATCH_HEAD. the BATCH_HEAD records
have an arbitrary number as their unique identifier
BATCH_NO. for auditing purposes these BATCH_NOs must be
sequential, there must be no gaps.
in days gone by when we had direct files (CISAM, etc) there
was no problem with this, just store the last number in a
single record key file, and lock and update it as necessary.
in oracle, we've has to use sequences because locking
doesn't work. this works well enough: the write of a
BATCH_HEAD record is done close enough to the number
getting pulled off the sequence that missing numbers are so
far not an issue.
time passes, specs change.
the system has been updated so that it is multi-company.
the number of companies is arbitrary and user-defined.
the BATCH_HEAD table is now keyed by company and batch_no.
the batch numbers must still be sequential and gapless, but
now within company: company 1 gets its own set of batches
within the table numbered 1 to m, and if company 2 exists
it does too, numbered 1 to n.
in CISAM the logic doesn't change much, you just add a
record to the key table for each company and retrieve
records by company. the lock, read, update, unlock
processing works just as well.
in oracle, however, things aren't so simple. i can think of
several ways to do this. each, however, requires a giant
mess of PL/SQL.
although excited by the prospect of writing densely
impenetrable logic i'd really rather try and keep things as
simple as possible.
anybody have any ideas?
many thanks,
mr s. <