First try at updatable views - Help!  
Author Message
Aleniko29139





PostPosted: Visual FoxPro General, First try at updatable views - Help! Top

OK - So I'm trying updatable views now.

I have a table with a few fields but there is no primary key.
I've created an updatable view, and I'm getting some update conflict errors.

I was wondering what's the proper way of doing this: Do I need to have a primary key in the table Should I create an autoincrementing field for that purpose

Thx.


Visual FoxPro2  
 
 
Budoi





PostPosted: Visual FoxPro General, First try at updatable views - Help! Top

Ideally you should have a primary key in the table. However, if there is a field in the table that you know will be unique across rows, then you could set that as your key in the View Designer's Upate Criteria tab. Alternatively, you can also set several fields as your key as long as those fields' combination will be unique among rows.

 
 
AndyKr





PostPosted: Visual FoxPro General, First try at updatable views - Help! Top

>> Do I need to have a primary key in the table

Absolutely! However it need not be a single column, nor does it have to be an autoincrementing integer. You can define your primary key as any combination of fields that uniquely identifies a record within a table.

The easiest, and best (for lots of reasons) way it to use a "surrogate" key whose only purpose is to act as the unique identifer and that is where your auto-incrementing integer comes in.

However you do it, you must define for the view, which field(s) it should use as the key to update the data