Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Relation
Message
From
15/05/2007 09:51:03
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01225516
Message ID:
01225520
Views:
21
>I have an invoice an its itens
>Both cursors are buffered as 4
>
>The ID field of the invoice_header.dbf has a relation
>with the ID of the iten.dbf
>
>I generate the ID of the invoice_header.dbf by
>
>***************************
>dimension lctemp[1]
>select max(ap.id2) from ap ;
> into array lctemp
> lcTemp[1] = nvl(lcTemp[1],0)+1
>replace ap.id2 with lctemp
>*******************************
>
>The code above is in the init event of the form
>
>Then, as itens are added :
>
>replace iten.id with invoice_heard.ID
>
>So I can see in the form, the header and its itens while they are added
>
>But this would cause problem in a network
>because the same ID could be generated
>by both operators
>
>How do you guys overcome it ?
>
>I would generate the ID only in the save method, but
>this way I would not be able to see the itens
>
>
>Moises

You shouldn't generate IDs this way. There are two acceptable ways:
1. Use auto-increment integer field
or
2. Use separate table keeping next sequential number for each table, and lock the record in this table by user request.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform