Load Blob PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

KB Help

HOW TO: Load a file or image into an Oracle BLOB Column using PowerCenter
Answer
Followingarethestepstoloadafile(MicrosoftWorddocumentinthisexample)usingaPowerCentersessionwithanOracleLoaderconnection: 1. Import a flat file source with the following data: 1,C:\Test.doc 2. 3. Import the Word Document as a Flat File target. Create a simple pass-through mapping as follows: Source [FF] > SQ > Target [FF] 4. 5. 6. 7. 8. Create an Oracle Loader connections under Connections>Loader. For Target flat file, make Connection Type as 'Loader' and Select the Oracle Loader created in Step 2. Under Set File Properties, select Delimited and Comma (',') as delimiter. Run the session to generate the control file (which will be generated in the Target Folder). Copy the following contents into the control file created by PowerCenter session and make it read only: LOAD DATA INFILE 'C:\Informatica\PowerCenter8.6.1\New\server\infa_shared\TgtFiles\word_document1.out' INTO TABLE Word_Document REPLACE FIELDS TERMINATED BY ',' (file_id, file_name, file_data LOBFILE (file_name) TERMINATED BY EOF)

Note
INFILE is pointing to the flat file which is created by PowerCenter with the data. 9. 10. This flat file will be loaded with the data (C:\Test.doc) read from the source. Runthesession. ThiswillloadtheWorddocumentintotheOracleTable.

Stored Procedure
Alternately, you can use an Oracle Stored Procedure and call the stored procedure in the mapping as post\pre target load or post-session command of any session.

Example
The following is a stored procedure which uses the DBMS_LOB package to read and load a .zip file into an Oracle database: *************** create table demo ( id int primary key, the Blob blob ) / create or replace directory my_files as '/export/home/tkyte/public_html'; declare l_blob blob; l_bfile bfile; begin insert into demo values ( 1, empty_blob() ) returning the Blob into l_blob; l_bfile := bfilename( 'MY_FILES', 'test.zip' ); dbms_lob.fileopen( l_bfile ); dbms_lob.loadfromfile( l_blob, l_bfile, dbms_lob.getlength( l_bfile ) ); dbms_lob.fileclose( l_bfile ); end; /

NOTE

Theseoptionscanbeusedtowriteorloadanyunstructuredbinaryfilessuchasimages(".jpg ", ".bmp ") files, compressed (" .zip ") files or proprietary file types such as Microsoft Word, etc.

More Information
The following are key points to consider when working with Binary Large Objects (LOBs) in Oracle: Internal LOBs associate with the transaction model of server and has a size limitation of 4GB. Internal LOBs are stored in the database as columns in a table while external LOBs are stored outside the database in operating system files. In your case, you can store it as a external LOB - as a BFILE so that it is stored on a disk. l Every LOB has a LOB Locator associated with it which can be viewed as a handle or pointer to the actual location of the LOB value. l Since only the LOB locator is stored in a row, when you query from a LOB column, Oracle only returns the LOB locator - not the entire value of the LOB. l Internal LOBs are stored in the database as columns in a table while external LOBs are stored outside the database in operating system files. In your case, you can store it as a external LOB - as a BFILE so that it is stored on a disk.
l l

Applies To
Database: Oracle Product: PowerCenter

Related Documents
HOW TO: Store an XML target file in an Oracle table as a CLOB object (KB 14895) "[Permission denied]. errno = 13]" while reading a loader control file with read and execute permission (KB 121133)

Last Modified Date:9/20/20114:49PM ID:101791

You might also like