Guarantee a Transaction

0

I have a table of Labels with the sequential RG incremented in the hand, as it zeros every day.

I have a Label registration screen where I pass the number of labels 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:

If I have two screens open, duplicate labels can happen. Is there a way around this?

    
asked by anonymous 17.04.2017 / 21:43

1 answer

0

A solution that can impact performance, but that will solve the problem is at each iteration of the loop you give the "select max + 1" in the rg field.

I'm not sure exactly how big your application and infrastructure is, depending on whether it's a bad idea or something tolerable.

One option you could try would be to leave this field as an auto increment, but there you have the issue of zeroing your count every day.

    
10.05.2017 / 21:20