Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness error
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01242809
Message ID:
01242892
Views:
11
>>>>>Vfp 9 SP1
>>>>Then you could use Integer AUTOINC instead of N(10).
>>>>That way you will be sure that you always will have a unique ID. There are some difficulties to get that Id back but all could be done.
>>>
>>>If you want to add children before you save the parent, you would not be able to do it with AutoInc field.
>>
>>And from where these children comes from?
>>Even orphans have some parents :-)
>>
>>You could add children firs, but then after you add parents you must update Parent(s) FK fields.
>>You could have a records like this:
>>
>>
>>Id   Parent1    Parent2
>>-------------------------
>>1     7           15 && Child
>>7     0            0 && First parent
>>15    0            0 && Second parent
>>
>
>
>Parent
>
>Id  Other fields
>
>Child
>
>ID ParentID  Other fields
>
>In the form I add a parent and a child. How can I know what ParentID to put in the Child table without saving parent first?
>
>This problem has no solution with autoincrement fields.

You could do this:
1. Save Child
2. Save Parents
3. Get parents IDs
4. Replace Parent IDs in Child record
5. Save Child (again)
:-)

But saving parents first is better :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform