View.Modify Method

Windows Installer

View.Modify Method

The Modify method of the View object modifies a database row with a modified Record object obtained by the Fetch method.

Syntax

Script
Modify(
  action,
  record
)

Parameters

action

Required action to be performed on the database row. This action is one of those shown in the following table.

Action name Meaning
msiViewModifySeek
–1

Refreshes the information in the supplied record without changing the position in the result set and without affecting subsequent fetch operations. The record may then be used for subsequent Update, Delete, and Refresh. All primary key columns of the table must be in the query and the record must have at least as many fields as the query.Seek cannot be used with multitable queries. See the remarks. This mode cannot be used with a view containing joins.

msiViewModifyRefresh
0

Refreshes the information in the record. Must first call the Fetch method with the same record. Fails for a deleted row. Works with both read-write and read-only records.

msiViewModifyInsert
1

Inserts a record. Fails if a row with the same primary keys exists. Fails with a read-only database. This mode cannot be used with a view containing joins.

msiViewModifyUpdate
2

Updates an existing record. Non-primary keys only. Must first call the Fetch method with the same record. Fails with a deleted record. Works only with read-write records.

msiViewModifyAssign
3

Writes current data in the cursor to a table row. Updates record if the primary keys match an existing row and inserts if they do not match. Fails with a read-only database. This mode cannot be used with a view containing joins.

msiViewModifyReplace
4

Updates or deletes and inserts a record into a table. Must first call the Fetch method with the same record. Updates record if the primary keys are unchanged. Deletes old row and inserts new if primary keys have changed. Fails with a read-only database. This mode cannot be used with a view containing joins.

msiViewModifyMerge
5

Inserts or validates a record in a table. Inserts if primary keys do not match any row and validates if there is a match. Fails if the record does not match the data in the table. Fails if there is a record with a duplicate key that is not identical. Works only with read-write records. This mode cannot be used with a view containing joins.

msiViewModifyDelete
6

Removes a row from the table. Must first call the Fetch method with the same record. Fails if the row has been deleted. Works only with read-write records. This mode cannot be used with a view containing joins.

msiViewModifyInsertTemporary
7

Inserts a temporary record. The information is not persistent. Fails if a row with the same primary key exists. Works only with read-write records. This mode cannot be used with a view containing joins.

msiViewModifyValidate
8

Validates a record. Does not validate across joins. Must first call the Fetch method with the same record. Obtain validation errors with GetError method. Works with read-write and read-only records. This mode cannot be used with a view containing joins.

msiViewModifyValidateNew
9

Validates a new record. Does not validate across joins. Checks for duplicate keys. Obtains validation errors by calling GetError method. Requires calling MsiDatabase.OpenView method with a modify value. Works with read-write and read-only records. This mode cannot be used with a view containing joins.

msiViewModifyValidateField
10

Validates fields of a fetched or new record. Can validate one or more fields of an incomplete record. Obtains validation errors by calling GetError method. Works with read-write and read-only records. This mode cannot be used with a view containing joins.

msiViewModifyValidateDelete
11

Validates a record that will be deleted later. Must first call the Fetch method with the same record. Fails if another row refers to the primary keys of this row. Validation does not check for the existence of the primary keys of this row in properties or strings. Does not check if a column is a foreign key to multiple tables. Obtain validation errors by calling the GetError method. Works with read-write and read-only records. This mode cannot be used with a view containing joins.

 

record

Required. Record object obtained by the Fetch method with modified field data.

Return Value

This method does not return a value.

Remarks

This method must be called after the Execute method.

To execute any SQL statement, a view must be created. However, a view that does not create a result set, such as CREATE TABLE or INSERT INTO, cannot be used with the Modify method to update tables though the view.

The msiViewModifyValidate, msiViewModifyValidateNew, msiViewModifyValidateField, and msiViewModifyValidateDelete values of the Modify method do not perform actual updates; they ensure that the data in the record is valid. Use of these actions requires that the database contain a _Validation table .

You cannot fetch a record containing binary data from one database and then use that record to insert the data into a completely different database. To move binary data from one database to another, you should export the data to a file and then import it into the new database using the SetStream method of the Record object. This ensures that each database has its own copy of the binary data.

Note  Custom actions can only add, modify, or remove temporary rows, columns, or tables from a database. Custom actions cannot modify persistent data in a database, such as data that is a part of the database stored on disk. For more information, see Accessing the Current Installer Session from Inside a Custom Action.

If the method fails, you can obtain extended error information by using the LastErrorRecord method.

Requirements

VersionWindows Installer 5.0 on Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003, Windows XP, and Windows 2000
DLLMsi.dll
IIDIID_IView is defined as 000C109C-0000-0000-C000-000000000046

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.