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



Solution

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

1.



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



2.



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

destination task.



3.



Create an OLEDB Connection Manager named CarSales_Staging_OLEDB which

establishes a connection to the CarSales_Staging database.



4.



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

5.



Click OK to confirm the provider.



6.



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

in the Connection Manager dialog box.



7.



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

Figure 4-2).



184

www.it-ebooks.info



Chapter 4 ■ SQL Databases



Figure 4-2.  The SSIS connection manager for Oracle

8.



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.



9.



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

(see Figure 4-3).



185

www.it-ebooks.info



Chapter 4 ■ SQL Databases



Figure 4-3.  Selecting an Oracle connection manager

10.



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



186

www.it-ebooks.info



Chapter 4 ■ SQL Databases



11.



Confirm your configuration with OK.



12.



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

Staging_OLEDB connection manager.



13.



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



14.



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

configuration.







Data type mapping is discussed in Appendix A.



187

www.it-ebooks.info



s



4-3. Accelerating Oracle Data Import

Problem

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



Solution

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:

1.



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/

en-gb/download/details.aspx?id=29284.



2.



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.



3.



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



188

www.it-ebooks.info



Chapter 4 ■ SQL Databases



4.



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

5.



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



6.



Double-click Source Assistant in the SSIS Toolbox.



7.



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.



189

www.it-ebooks.info



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)

×