Win32-MSI-DB

 view release on metacpan or  search on metacpan

DB.pm  view on Meta::CPAN

=head2 Using transforms

When you have got a handle to a database, you can successively apply
transforms to it.  You do this by using C<transform>, which needs the
filename of the transform file (normally with extension F<.mst>) and
optionally a flag specification.

Most of the possible flag values specify which merge errors are to be
suppressed.

=over 4

=item $Win32::MSI::MSITR_IGNORE_ADDEXISTINGROW

Ignores adding a row that already exists.

=item $Win32::MSI::MSITR_IGNORE_ADDEXISTINGTABLE

Ignores adding a table that already exists.

=item $Win32::MSI::MSITR_IGNORE_DELMISSINGROW

Ignores deleting a row that doesn't exist.

=item $Win32::MSI::MSITR_IGNORE_DELMISSINGTABLE

Ignores deleting a table that doesn't exist.

=item $Win32::MSI::MSITR_IGNORE_UPDATEMISSINGROW

Ignores updating a row that doesn't exist.

=item $Win32::MSI::MSITR_IGNORE_CHANGECODEPAGE

Ignores that the code pages in the MSI database and the transform file
do not match and neither has a neutral code page.

=item $Win32::MSI::MSITR_IGNORE_ALL

This flag combines all of the above mentioned flags.  This is the
default.

=item $Win32::MSI::MSITR_VIEWTRANSFORM

This flag should not be used together with the other flags.  It
specifies that instead of merging the data, a table named
C<_TransformView> is created in memory, which has the columns
C<Table>, C<Column>, C<Row>, C<Data> and C<Current>.

This way the data in a transform file can be directly queried.

For more information please see
S<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/_transformview_table.asp>.

=back

This doesn't open the file read-only, but changes will not be written
to disk.

A transform is a specification of changed values.  So you get a MSI
database from your favorite vendor, make a transform to overlay your
own settings (the target installation directory, the features to be
installed, etc.) and upon installation you can use these settings via
a commandline similar to

  msiexec /i TRANSFORMS = F<your transform file> F<the msi database> /qb

The changes in a transform are stored by a (table, row, cell, old
value, new value) tuple.

=head2 Fetch records from a table or view

When you have obtained a C<table> or C<view> object, you can use the
C<record> method to access individual records.  It takes a number as
parameter.  Records are fetched as needed.  Using C<undef> as parameter
fetches all records and returns the first (index 0).

Another possibility is to use the C<records> method, which returns an
array of all records in this table or view.

=head2 A record has fields

A record's fields can be queried or changed using the C<record>
object, as in

  $rec->set("field", "value"); # string
  $rec->set("field", 4);       # int
  $rec->set("field", "file");  # streams

  $rec->get("field");
  $rec->getintofile("field", "file");

or you can have separate C<field> objects:

  $field = $rec->field("field");

  $data = $field->get();
  $field->set(2);

Access to files (streams) is currently not finished.

=head2 Errors

Each object may access an C<error> method, which gives a string or an
array (depending on context) containing the error information.

Help wanted: Is there a way to get a error string from the number
which does not depend on the current MSI database?  In particular, the
developer errors (2000 and above) are not listed.

=head1 REMARKS

This module depends on C<Win32::API>, which is used to import the
functions out of the F<msi.dll>.

Currently the C<Exporter> is not used - patches are welcome.

=head2 AUTHOR

Please contact C<pmarek@cpan.org> for questions, suggestions, and
patches (C<diff -wu2> please).



( run in 1.335 second using v1.01-cache-2.11-cpan-98e64b0badf )