JavaScript Editor js editor     Web development 

Main Page

To update data in a view, make sure that the options and properties that control updates for views are set so that the view can be updated. For more information, see Preparing to Update Views.

The default view properties might provide all the information needed so that your view can be updated.

To view options for updating a view

  • Open the view in the View Designer, and click the Update Criteria tab.

    The Update Criteria tab displays the update settings for the view.

For more information, see How to: Edit Views and Update Criteria Tab, View Designer.

To set properties for updating a view

  1. Use the DISPLAY DATABASE command to display the current property settings for the view.

  2. Use the DBSETPROP(В ) function to modify the property settings for the view.

For more information, see DBSETPROP( ) Function.

When you use DBSETPROP(В ) to set properties on a view before you use the view, the settings are stored in the database and are used automatically whenever you activate the view. Once the view is active, you can use CURSORSETPROP(В ) to change property settings on the active view. Property settings you set on an active view with CURSORSETPROP(В ) are not saved when you close the view.

The following example lists the steps you would follow to specify the five view update properties programmatically:

  1. Set the Tables property with at least one table name.

    For example, if you have a view based on the customer table called cust_view, you could set the table name with the following function:

    В Copy Code
    If a table appears as a qualifier in the UpdateName property but is not included in the default list for the Tables property, the table might not have a primary key field specified. Make the table updatable by adding the field you consider to be a key field to the KeyField property list, and then add the table to the Tables property list.

  2. Set the KeyField property with one or more local Visual FoxPro field names that together define a unique key for the update table.

    Using the same example, you could make cust_id the key field using the following code:

    В Copy Code
    Be sure the key field(s) you specify define a unique key both in the base table you want to update and in the view.

  3. Map the view fields to their base table fields with the UpdateName property. This property is particularly useful when your view is based on a join of two tables with a common field name, or when the fields are aliased in the view. To update the desired base table, you map the Visual FoxPro view field name to the base table field and table name.

    В Copy Code
    To avoid creating synonym fields in your view, you can qualify field names in the SQL statement you use to build your view. Then use the Visual FoxPro UpdateName property of the view to map each qualified field to the correct base table and field name.

  4. Specify the scope of fields you want to update with the Updatable property. You should specify only those fields also specified with the UpdateName property.

    В Copy Code
    DBSETPROP('cust_view.cust_id','Field','Updatable', .T.)
  5. Set the SendUpdates property to True (.T.). The SendUpdates property controls whether to create and send updates to the tables and fields that can be updated.

    В Copy Code

See Also

JavaScript Editor js editor     Web development