The BinaryReader and BinaryWriter Java Transformations

BinaryReader and BinaryWriter Java Transformations

Contents

1. The BinaryReader Transformation a. Transformation Type b. Ports Overview c. Using the BinaryReader - Example

2. The BinaryWriter Transformation a. Transformation Type b. Ports Overview c. Using the BinaryWriter ? Example

3. How to use BinaryReader/BinaryWriter Transformations in PowerCenter a. Xml import b. Creating transformations

1. The BinaryReader Transformation

Transformation type: ? Passive ? Connected

Use the BinaryReader transformation to read any binary file as a source. The BinaryReader transformations

The following shows the BinaryReader Java Transformation, its Input and Output ports:

Ports Overview:

Sl Name 1 FileName

2 File_ID

3 BinaryOut

4 MD5

Input/Output Input

Input & Output

Output

Output

Description

Connect a string field from a source which has the name of the file to be read and transformed into a binary field. This is an optional field which has the ID of a file. Can be used to identify a file like a number, file id etc This field is of the binary datatype which can be connected to either a binary target or an instance of a BinaryWriter java transformation. The MD5 hash (string length 32) of the file when it is successfully read.

Example: To write images into an Oracle table's BLOB field:

Consider the following set of values to be loaded onto an Oracle table. The IMAGE_PATH field is a string field in this source and the actual image in the form of binary has to be loaded to the BLOB field in the target table.

Source data:

SSN

987-65-4320 987-65-4321 987-65-4322 987-65-4323

FIRST_NAME LAST_NAME IMAGE_PATH

Lloyd Miriam Brad Kyle

Warren Ruiz Moore Henderson

E:\ID_Pic01.jpg E:\ID_Pic02.jpg E:\ID_Pic03.jpg E:\ID_Pic04.jpg

Source (Flat file):

Target (Oracle):

Create a mapping using the BinaryReader Java Transformation to write the required data (images as BLOB) to the Oracle target.

2. The BinaryWriter Transformation

Transformation type: ? Passive ? Connected

Use the BinaryWriter transformation to write a binary stream as a file, to file system. You can connect any binary field from a source to the BinaryWriter transformation.

The following figure shows the BinaryReader Transformation's Input and Output groups' ports:

Ports Overview:

Sl Name 1 Binary_IN

2 FileName 3 OutString

Input/Output Input

Input Output

Description

Connect a binary field from a source which has the binary data that has to be transformed into a file on the file system. The name of the file created by the BinaryWriter transformation is given by the FileName field. The FileName field is the absolute path of the file to be created. The MD5 hash of the file when it was written.

Example: To read binary (as images) from Oracle table's BLOB field: Consider the following set of values to be loaded onto an Oracle table. The IMAGE_PATH field is a string field in this source and the actual image in the form of binary has to be loaded to the BLOB field in the target table. In this example, an Expression transformation is used to modify the filenames in the format: _.jpg The expression used in this example is:

'E:\\card_images\\' || First_Name || '_' || Last_Name || '.jpg'

The absolute path to the file must be given in the FileName field. Source (Oracle):

Create a mapping using the BinaryWriter Java Transformation to create the file on the file system.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download