Requirements

When migrating directly from an Oracle database, which is accessible to the destination server where you're running Migrate, use the MigrateSourceOracle source class. To use this class, you must have the oci8 extension installed and enabled in PHP.

Usage

The constructor takes five arguments, all but the last required.

Configuration array

The first argument contains the connection info for your source database. The array elements are:

connection_string: An Oracle connection string like '//oracledb/orcl'.

username: The username to connect under.

password: That user's password.

query

The SQL query to obtain the source data. It is important to understand that the query you use as your source must return a single row for each object to be created. While it may seem natural at first blush to join to, say, a "category" table which has multiple rows for a given content item, that will produce multiple rows in the source query - see the advanced topic Multiple source data rows for suggestions on dealing with such situations.

count_query

A SQL query to count the rows in the source data.

fields

An array describing the data returned by the query, keyed by the column name (case-sensitive) with a description of the field contents as the value.

options (optional)

An array of options affecting the behavior of the source class:

character_set: The character set to pass to the Oracle connection - if not set, it defaults to 'UTF8'.

The standard source options are also supported.

Example

For the complete example, see the migrate_example_oracle module bundled with Migrate.

In settings.php:

 $conf['oracle_db'] = array(
   'username' => 'DRUPAL',
   'password' => 'DRUPAL',
   'connection_string' => '//oracledb/orcl',
 );

In your migration constructor:

$fields = array(
  'OID' => t('Source id'),
  'TITLE' => t('Title'),
  'BODY' => t('Description'),
  'MAINIMAGE' => t('Main image'),
  'CREATED' => t('Creation date'),
  'UPDATED' => t('Updated date'),
);
$query = "SELECT OID, TITLE, BODY, MAINIMAGE, TO_CHAR(CREATED, 'yyyy/mm/dd hh24:mi:ss') CREATED,
            TO_CHAR(UPDATED, 'yyyy/mm/dd hh24:mi:ss') UPDATED
          FROM ORACLE_CONTENT";
$count_query = "SELECT COUNT(*) FROM ORACLE_CONTENT";

$this->source = new MigrateSourceOracle(variable_get['oracle_db'], array()), $query,
  $count_query, $fields);