# Exporting source data and making the data files accessible

Perform the following steps only if you plan to import data using files. These steps export the data in the source database and make the files accessible to the Empirica Healthcare Analysis database.

These steps create separate export files for the data and vocabulary accounts and include directions on how to modify commands if the vocabulary account is part of the data account.

Perform these steps before you set installation and data transfer settings.

Step 1. Create the export directory in the source database.

You can use the default DATA_PUMP_DIR directory or create a new directory. Oracle recommends creating a new directory.

1. Using SQL*Plus, log in to the source database as SYS.
2. Create the directory, pointing to a valid and accessible location on the server:

   SQL>create or replace directory <export_directory> as '<server_path>';

   where:

   - <export_directory> is the name of the directory to which you are exporting data.
   - <server_path> is the path to the server location that exported files will be written to.

   Example:

   SQL>create or replace directory ETL_SRC_DIR as '/u01/oradata/xxx';

Step 2. Give privileges to the source user accounts for the export directory.

- Use the following commands to give privileges to the user accounts in the source database that will be exported.

  If the vocabulary account is the same as the data account, omit the second command.

  SQL>GRANT READ, WRITE ON DIRECTORY <export_directory> TO <data_schema_name>;

  SQL>GRANT READ, WRITE ON DIRECTORY <export_directory> TO <vocabulary_schema_name>;

  where:

  - <export_directory> is the name of the directory to which you are exporting data.
  - <data_schema_name> is the name of the account for the data tables in the source database.
  - <vocabulary_schema_name> is the name of the account for the vocabulary tables in the source database.

  Example:

  SQL>GRANT READ, WRITE ON DIRECTORY ETL_SRC_DIR TO CDM_SOURCE;

  SQL>GRANT READ, WRITE ON DIRECTORY ETL_SRC_DIR TO CDM_VOCABULARY;

Step 3. Export the source data, either all of the tables or the tables of your choosing.

If you export all the tables, tables that are not needed are exported. For instance, you need only one condition table.

Export the tables along with their indexes and constraints. You do not need to export other objects in the account.

- To export all the data, use the following commands.

  If the vocabulary account is the same as the data account, omit the second command.

  You are prompted to provide a password for each account.

  Commands for Oracle 11g:

  $expdp <data_schema_name>@<connect_string> directory=<export_directory> dumpfile=<dump_file_name>.dmp logfile=<log_file_name>

  $expdp <vocabulary_schema_name>@<connect_string> directory=<export_directory> dumpfile=<dump_file_name>.dmp logfile=<log_file_name>

  Commands for Oracle 12c:

  $expdp <data_schema_name>@<connect_string> dumpfile=<export_directory>:<dump_file_name>.dmp logfile=<export_directory>:<log_file_name>

  $expdp <vocabulary_schema_name>@<connect_string> dumpfile=<export_directory>:<dump_file_name>.dmp logfile=<export_directory>:<log_file_name>

  where:

  - <data_schema_name> is the name of the account for the data tables in the source database.
  - <vocabulary_schema_name> is the name of the account for the vocabulary tables in the source database.
  - <connect_string> is the connect string for the source database, one of the following:
    - A net service name that is specified in the tnsnames.ora file on the Empirica Healthcare Analysis database server and that indicates how to connect to the source server.
    - An EZCONNECT connection string in the following format: hostname:port/service
  - <export_directory> is the name of the directory to which you are exporting data.
  - <dump_file_name> is the name to use for the dump file that is created.
  - <log_file_name> is the name to use for the log file that is created.

  Example for Oracle 11g:

  $expdp cdm_source@ORCL directory=ETL_SRC_DIR dumpfile=data_export.dmp logfile=data_export.log

  $expdp cdm_vocabulary@ORCL directory=ETL_SRC_DIR dumpfile=voc_export.dmp logfile=voc_export.log

  Example for Oracle 12g:

  $expdp cdm_source@ORCL dumpfile=ETL_SRC_DIR:data_export.dmp logfile=ETL_SRC_DIR:data_export.log

  $expdp cdm_vocabulary@ORCL dumpfile=ETL_SRC_DIR:voc_export.dmp logfile=ETL_SRC_DIR:voc_export.log

- To export only a set of specific tables:
  1. Decide upon the data tables to export. For a list of the options, see Tables that are copied from the source database.
     - The following tables are required for all exports: PERSON, OBSERVATION_PERIOD
     - You must export at least one of the following tables: DRUG_ERA, DRUG_EXPOSURE
     - You must export exactly one of the following tables: CONDITION_ERA, CONDITION_OCCURRENCE
     - The following table is optional: PROCEDURE_OCCURRENCE
  2. If you have a vocabulary account, decide whether to export only the CONCEPT table.
  3. Add a space to the last letter of each of the previous commands, and add the following text:

     TABLES=<table_list>

     where:

     - <table_list> is the comma-delimited list of tables to export from the source database.

     Example:

     $expdp cdm_source/cdm_source@ORCL directory=ETL_SRC_DIR dumpfile=data_export.dmp logfile=data_export.log TABLES=PERSON,OBSERVATION_PERIOD,DRUG_ERA,DRUG_EXPOSURE,CONDITION_ERA,PROCEDURE_OCCURRENCE

     $expdp cdm_vocabulary/cdm_vocabulary@ORCL directory=ETL_SRC_DIR dumpfile=voc_export.dmp logfile=voc_export.log TABLES=CONCEPT

Step 4. Move the export files you created in step 3 to the import directory location on the Empirica Healthcare Analysis database server.

You can move the files using a tool of your choice, such as an sFTP client.

Step 5. Create a database directory on the Empirica Healthcare Analysis database server machine.

1. Using SQL*Plus, log in to the Empirica Healthcare Analysis database as SYS.
2. Create a directory, pointing to a valid and accessible location on the server:

   SQL>create or replace directory <import_directory> as '<server_path>';

   where:

   - <import_directory> is the name of the directory from which you are importing data.
   - <server_path> is the path to the server location that will contain the data files you will import from.

   Example:

   SQL>create or replace directory ETL_SRC_DIR as '/u01/oradata/xxx';

Copyright © 2015 Oracle and/or its affiliates. All rights reserved.