Tải bản đầy đủ - 0 (trang)
4-2. Importing Data from Oracle As a Regular Process

4-2. Importing Data from Oracle As a Regular Process

Tải bản đầy đủ - 0trang

Chapter 4 ■ SQL Databases


Implement an SSIS package to load the data. Follow these steps to do it:


Open or create an SSIS package. Add a Data Flow task to the Control Flow pane.


Double-click the Data Flow task to edit it. Add an OLEDB source and an OLEDB

destination task.


Create an OLEDB Connection Manager named CarSales_Staging_OLEDB which

establishes a connection to the CarSales_Staging database.


Right-click the Connection Managers tab at the bottom of the screen and select New

OLEDB Connection. Click New. In the list of providers, select the Oracle Provider for

OLEDB. You should see something like Figure 4-1.

Figure 4-1.  Selecting the Oracle Provider for OLEDB


Click OK to confirm the provider.


Enter the Address name from the TNSNames.ora file as the Server or File Name

in the Connection Manager dialog box.


Enter the Oracle logon information in the Connection Manager dialog box (see

Figure 4-2).



Chapter 4 ■ SQL Databases

Figure 4-2.  The SSIS connection manager for Oracle


Test the connection. If the message indicating a successful connection is confirmed,

click OK to finish creating the connection manager. Rename it ORCLAdam—or a

name that suits your requirements.


Double-click the OLEDB source task. Select the connection manager you just defined

(see Figure 4-3).



Chapter 4 ■ SQL Databases

Figure 4-3.  Selecting an Oracle connection manager


Select the table or view in the source database that you wish to use. Alternatively,

set the data access mode to SQL command and write the SQL to select the data. The

source dialog box should look like Figure 4-4.

Figure 4-4.  The OLEDB Source Editor for SSIS to select Oracle data



Chapter 4 ■ SQL Databases


Confirm your configuration with OK.


Link the OLEDB source task to the destination task. Configure it to use the CarSales_

Staging_OLEDB connection manager.


Click “New” to create a new table. Click “OK” to confirm.


Map the columns in the destination task. Confirm that the destination task is correct.

The full details of this are described in Recipe 1-7, among many others.

You can now run the SSIS package and import the source data.

How It Works

Fortunately, importing external data using SSIS is extremely simple. I will presume here that you know basic SSIS

because there are many examples of SSIS data import in this book, so I have not explained every detail. The point

here is to concentrate on the OLEDB link to the Oracle database. Once this is working, the rest should be easy.

However, as described in the Recipe 4-1, Oracle has a clear set of prerequisites:

You need the Oracle client to be installed on the SQL Server.

You must ensure a working network connection to the Oracle server.

You need an Oracle user logon and password with rights to the data you wish to retrieve.

Hints, Tips, and Traps

In a large, “real-world” Oracle data load situation, you are probably better advised to

create the connection manager at package level (in the Connection Managers folder of

the Solution Explorer) if you are using SQL Server 2012. This is because you are likely to

be using it many times across multiple packages to source many (many) tables.

You could get a Column Code Page warning at step 11. To avoid it, remember that you

can use the Advanced Editor to set the AlwaysUseTheDefaultCodePage property of the

Component Properties tab to True. The DefaultCodePage can be set to 1252, which is

fine for most Western languages. If Oracle is using another character set, you will need to

determine which one and select an equivalent in SSIS.

As BIDS/SSDT is (still) a 32-bit tool, you will only see the Oracle OLEDB provider on a

64-bit computer if both 32-bit and 64-bit Oracle providers have been installed, as

described in Recipe 4-1.

Some Oracle source tables do not use a precision with the NUMBER data type. This can

cause an issue with SSIS, and you may need to add the precision. The simplest way to

carry this out is to use the Oracle CAST or CONVERT functions in the SQL used to extract the

source data in step 9.

When configured for an Oracle provider, the Connection Manager dialog box will not list

all available catalogs.

In a production environment, presumably, you store the password as part of a package


Data type mapping is discussed in Appendix A.




4-3. Accelerating Oracle Data Import


You have to load a quantity of Oracle data that will take longer to load than you have time available.


To accelerate the data load, use the Attunity SSIS Connectors for Oracle, which are available with the SQL Server

Enterprise edition. The following explains how you can do this:


Download the Attunity SSIS Connector for Oracle that corresponds to your

environment (32-bit or 64-bit). They are currently available at www.microsoft.com/



Double-click the .msi file and install the connector. You can modify some of the

installation parameters, but accepting the defaults is nearly always easier.


In an SSIS package, right-click inside the Connection Managers tab and select

MSORA in the Add SSIS Connection Manager dialog box. The dialog box should look

like Figure 4-5.

Figure 4-5. Adding an Attunity SSIS connection manager



Chapter 4 ■ SQL Databases


Click OK and add all the required connection parameters. These are essentially the

same ones described in step 6 of Recipe 4-2. The dialog box should look like Figure 4-6.

Figure 4-6.  Configuring the Attunity connection manager for Oracle


Add a Data Flow task to the SSIS package. Double-click to edit.


Double-click Source Assistant in the SSIS Toolbox.


Select Oracle as the source type in the left pane. Select the connection manager that

you just created in the right pane. The dialog box should look like Figure 4-7.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

4-2. Importing Data from Oracle As a Regular Process

Tải bản đầy đủ ngay(0 tr)