Jump to content

Serial number nightmare!


This topic is 6191 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi everyone,

I have an interesting problem with a multi-user database I've written to make prodution sheets.

There are 20 user using this database at the same time. When a user makes a new record a serial is automatically generated by the serial field. This is coupled to a script like the one below.

Allow User Abort [off]

Set Error Capture [On]

Go to layout ["Num_Jobs" (Num_Jobs)]

Insert Calculated Result( GetNextSerialValue (Num_Jobs" ; "Number Job Numeris")]

Set Next Serial Value [Num_Jobs::Number Job Numeris; Num_Jobs::Number Job Numeris + 1]

New Record/request

When a user creates a record and another user creates a record lets say 30 sec to a minute later they get the same serial assigned!

I scratched my head what could be the cause, but running out of ideas. Is there an issue with the script or the field validation?

Thanks for advice, because I'm out of ideas and pressure is building.

Link to comment
Share on other sites

... and this is perciously why this kind of method can not be trusted as serial numbers. You should use FM auto-generated serial numbers only for true unique serial numbers.

Link to comment
Share on other sites

how do you reset the serial number when a user deletes a record

You don't. How could you - when you have 20 users? Suppose User A creates record #5. Immediately afterwards, User B creates record #6. Now User A wants to delete their record (#5). What would you reset the serial number to?

Link to comment
Share on other sites

"the user wanted to be sure there were no gaps in the Invoice Numbers"

Simple: disable delete. Cancel invoices instead.

I've done similar "centralised serial number" systems before, and none can prevent gaps, as Comment and others have said.

I've stored the serial number in a dedicated, single record "preferences" table set up just for the purpose. Scripts that increment the serial number have to trap for record locking, and be sure to open and close the record when they are done -- do everything quickly to minimise clashes.

You've also go to think about what should happen if the serial number cannot be incremented for, say, 30 seconds: should the process be aborted or should the user be kept waiting while the process continues trying. (To be honest, 30 seconds is way too long, 5 seconds would be more reasonable. A 30 wait would mean that sonething is relly wrong.) If the process is aborted then the new invoice (or whatever) needs to be rolled-back or deleted.

If that all sounds complicated, it's because it is. But it's needed for a robust and reliable system mission-critical system.

Which is why it's best to convince the system owners that invoice or serial numbers with no inherent meaning are the way to go.

Link to comment
Share on other sites

I don't think it needs to be complicated - provided you either forbid deleting, or allow gaps.

Even re-using deleted numbers should be possible, if a bank of numbers is kept in a pre-generated table (could be script-incremented with each posted record). However, an invoice dated later than the "next" invoice may be considered evidence of accounting fraud.

Link to comment
Share on other sites

This topic is 6191 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.