Accessing Iseries DB2 in SSIS
Accessing Iseries DB2 in SSIS
com
-1-
www.tobuku.com
Creating a DSN
When using an ODBC driver, a definition of a Data Source Name (DSN) is necessary to specify the database parameters such as the server name, database name, user ID etc. 1. Go to Control Panel Administrative Tools Data Sources (ODBC)
2. In the ODBC Data Source Administration window, select User DSN or System DSN and press Add to create a new data source. The System DSN is actually more preferred rather than the User DSN. Later the NOTE box in the following page will explain the reason.
4. In the General tab, please specify the Data source name and the System name (the server name of the iSeries machine).
-2-
www.tobuku.com
5. In the Server tab, type the SQL default library. This is the library that will be used after the user is successfully connected to the server.
-3-
www.tobuku.com You may set the Connection type as Read-Only or leave it as default. Normally the SQL command sent to the server is only SELECT commands that will not change the data; besides the iSeries sysadmin is usually very strict concerning the data security. Although the connection is Read/Write, but if the user right given is read-only then you still will not be able to change the data after all. 6. Press OK to save the new DSN.
NOTE: When creating a new DSN, usually the most preferred type is the System DSN rather the other DSN type, i.e. User DSN and File DSN. The reason is because the System DSN works for anyone using that system, no matter who logs onto the machine, the system DSN can be seen by all users. For example you log in to the server to create the DSN, but eventually the user who will use the DSN is the SQL service account. If the User DSN is used, most likely the SQL service account will not find the DSN youve created. The System DSN normally works fine in most of the cases. However I find a pretty strange thing in one of my SQL Server installations. If I create a System DSN or User DSN then the DSN cannot be found by the SSIS package although it is there in the ODBC Data Source Administrator however if I create a File DSN, then it will appear. So specifically for this server, I use the File DSN. Honestly I cannot explain this anomaly because in other computer we use System DSN and works fine. My suggestion is to use a System DSN as far as it works - but if it doesnt, then try to use the File DSN.
-4-
www.tobuku.com
3. Choose the provider as .Net Providers/Odbc Data Provider, and select the DSN youve just created from the list box. Do not forget to specify the User name and the Password. See the picture below. If you cannot find the DSN, you probably have the same problem with mine as explained in the NOTE box earlier (about the anomaly). If that is the case, then you should choose the User Connection string option followed by pressing the Build button. In the next window, select the DSN from the File DSN (thats why you must create the File DSN first). Upon finished, the connection string is automatically built for you. The Build button is very helpful as the DSN cannot be selected, the database connection string must be typed but this kind button do that for us from the defined File DSN.
-5-
www.tobuku.com
4. Click the Test Connection button to verify the configuration. Press OK when everything works fine. After finished creating the IBM iSeries DB2 data source connection, you may continue with the destination data connection, for example SQL Server, Text or Excel. Typically the OLE DB Connection is used for the SQL Server data connection. When all data connections have been properly set up, then the SSIS package is ready to be developed. 1. Drag a Data Flow Task from the Toolbox to the design pane and then double-click to open it.
2. Now we want to specify the data source of the Data Flow task, in this case is the IBM iSeries DB2. Drag an ADO NET Source and double-click to open it. Select the data source from the ADO NET Connection created earlier.
-6-
www.tobuku.com 3. In the Data Flow task, normally the source connection can be linked directly to the destination connection; i.e. the source columns are mapped one by one to the destination columns. However when the iSeries DB2 is used as the source data, the link should not be made directly because of the incompatibility data type between iSeries DB2 and SQL Server. We need a middle part in between those connections that convert the data type from the source to the destination. To do that, drag a Data Conversion from the Toolbox to the design pane. Actually not all columns need to be converted. We must pay attention on source columns only those with the text data type while the other columns with numeric data type typically do not need to be converted. The input columns need to be mapped as String (DT_STR) or Unicode string (DT_WSTR) becoming output alias. Dont forget to specify the length too. This document does not explain in detail how to do the data conversion. Please refer to the SQL Server Online Book or the other resource how to do that. Right after the Data Conversion, drag a destination connection and link it with the previous component as shown in the following picture. For the purpose of easier explanation in this document, lets assume the destination connection is SQL Server.
NOTE: If the destination is a SQL Server database, then SQL Server Destination or OLE DB Destination can be chosen.
The rest of the project are the same with the other SSIS package, please complete it by your self.
-7-
www.tobuku.com
-8-
www.tobuku.com
-9-
www.tobuku.com 2. Switch to the Data sources tab, place the check marks on all existing data connections.
- 10 -
www.tobuku.com 3. Go to the Command line tab, and choose Edit the command line manually. As you do that, the Command line text box becomes enabled and you are able to edit the command line. Find the text User ID= or uid=, then add the text Pwd=<enter the password> manually. The picture below shows the illustration. Dont forget to add the ; character to separate the parameters.
Thats all. Save the Job and its ready for action.
- 11 -