Manually get a sequence number

How would I manually go about getting the next sequence number?  


I'll explain what I am trying to do to make things a little clearer.  I am storing weights from a scale, the scale provides serial numbers for each weight which I save in the database but occasionally I need to take a manual weight, i.e. prompt the user for the weight and store that.  When I did this in the past I used a Firebrid generator to get the next manual serial number and saved that.  So is there a way a database independent way I can get the next sequence number along the same lines as the sequence and ID attributes do?

Unfortunately there is no such way, since some databases use identities. Whatever you do, will be database-dependant. I don't understand the part you say "scale provides serial numbers", though. Are you using a table with automatic id or not? And if yes, also didn't understand why you need to take the next value manually? Can't you just create a new record to get the new number and then fill the remaining data?

When I go and get a real weight from the scale the scale has its own internal record of all the weights it has taken and sends it's serial number along with the weight.  So for each weighing I record in the my database the weight and serial number I get from the scale along with an identifier for the specific scale that provided the weight.  However sometimes users need to record weights manually, for example they might know the tare weight of a truck and just want to type it in without actually weighing it.  In this case I have to make up my own serial number which I used a generator for in the past.


Anyway I've got round it by just getting the maximum serial number for manual weights and just add one to it.  I don't think there will be any concurrency issues.

  MaxSerialNo := FManager.Find<TTallyRoll>
    .SetProjections(TProjections.Max(dic.TallyRoll.SerialNo.PropName))
    .CreateAlias(dic.TallyRoll.WeighbridgeID.AssociationName, 'W')
    .Add(TExpression.Eq('W.ID', ManualWeighbridgeID))
    .UniqueValue;

Thanks for your help, I have another question too, sorry to be a pain. I'll post it as a new subject as it's not the same issue.