0
I have a table of Tags with sequential ID incremented in hand, because it Zera every day.
I have a Tag registration screen where I pass the amount of tags to be generated:
Vrg := Select MAX onde eu pego o maior RG.
qtETQ := quantidade de etiquetas, por exemplo 500 etiquetas digitada pelo usuario
i := 0
while i <= qtEtq do //loop de 500 vezes
begin
Vrg := Vrg+1
etiqueta.rg := Vrg
etiqueta.post
end
My question is this::
If I have two screens open, they can happen to have duplicate labels. There’s a way around that?
an alternative is before you enter in the database check if there is already a label registered with that rg, if there is a new code or keep adding.
– Jefferson Rudolf
I don’t know if you give the commit only at the end of the loop or the sticker. already commit the information in the bank. However commit be given only at the end (recommended), I suggest you work with a quence (as Oracle does). If it is not Oracle, you can simulate a quence, ensuring the exclusivity of the label.
– Andrey
@Andrey how do I simulate this Quence in Delphi? I’m using Firebird
– Tiago Casanova
You can ride a Generator on Firebird and each day when it is the first access to reset the Generator (In this case the SGDB itself will guarantee the unique RG). If you try to control the application level, either leave the table in Lock or commit to each new record.
– Andrey
The application even shows some error?
– William