Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to save more views which depends on each other

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Next scenario in VFP9
I am only using updatable views with autoinc field as primairy key.
"Master" view is easy to handle, just do append blank "et voila!"
Than I do have on same dataform another (some even several) views for the relation which need the primairy key of 'The Master' as one of their fields in new records.

"The master's" primairy key is only available after a tableupdate().

What is good scenario to follow for saving these views ?

Currently I do have in framework the '10001-things' solution. Holding transaction to be sure 'all or nothing' is saved in the proper way.

Pls advice.

-Bart
 
Well, yes, putting everything into a transaction should be helpful.

Once you tableupdate() the parent table and requery() it you will have the ids, you can then update the child view/table records with the correct values.

If you add several parent records you will need to store preliminary IDs as primary and foreigen key values, eg -1,-2,-3, etc. And then need to have a translation cursor with preliminary and real ID.

It's easier to not use Autoinc in this situation, but use the oldstyle way of creating IDs with a stored proc, updating an ID table. This way you can create IDs before saving to the DBF files.

Or use GUIDs as keys.

Bye, Olaf.
 
Hi Olaf,
A be late reply but I had some dasys off.
The solution is found using the function GETAUTOINCVALUE as described in the book "What's new in nine".
Anyway thanks for your contribution in solving this problem.
-Bart
 
GETAUTOINCVALUE may not give you the right answer in cases many users insert many rows simultaneous. Seldom case, but it has the same downside as SQL Servers @@Identity or SCOPE_IDENTITY(). That said I also use the latter when working with SQL Server, so it's quite a valid solution.

Still you could cascade the real primary key you get from Master Tableupdate for child views etc.

Bye, Olaf.
 
Hi Olaf, Thanks for your additional info.
But, as far as my knowlege, using getautoincvalue together with a transaction inwhich the child-views are updated is save though? Independent of what other user sare doing. Isn't it that tables are locked during transactions?
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top