locked
First try at updatable views - Help! RRS feed

  • Question

  • 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.
    Thursday, December 7, 2006 4:34 AM

Answers

  • 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.
    Thursday, December 7, 2006 6:14 AM
  • >> 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

    Thursday, December 7, 2006 12:57 PM

All replies

  • 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.
    Thursday, December 7, 2006 6:14 AM
  • >> 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

    Thursday, December 7, 2006 12:57 PM