Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

Part Number E17727-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

CopyFromFile (OraLOB) Method

Applies To

OraBLOB, OraCLOB Objects

Description

Loads or copies a portion or all of a local file to the internal LOB value of this object.

Usage

OraBlob.CopyFromFile "blob.bmp" amount, offset, chunksize 
OraClob.CopyFromFile "clob.txt" amount, offset, chunksize 

Arguments

The arguments for the method are:

Arguments Description
[in] filename A string specifying the absolute name and path for the file to be read.
[in] [optional] amount An Integer specifying the maximum number in bytes to be copied. Default value is total file size.
[in] [optional] offset An Integer specifying the absolute offset of the BLOB or CLOB value of this object, in bytes for OraBLOB or OraBFILE and characters for OraCLOB. Default value is 1.
[in] [optional] chunksize An Integer specifying the size for each read operation, in bytes. If chunksize parameter is not set or 0, the value of the amount argument is used, which means the entire amount is transferred in one chunk.

Remarks

Obtain either a row-level lock or object-level lock before calling this method.

The file should be in the same format as the NLS_LANG setting.

Note:

When manipulating LOBs using LOB methods, such as Write and CopyFromFile, the LOB object is not automatically trimmed if the length of the new data is smaller than the old data. Use the Trim (OraLOB) method to shrink the LOB object to the size of the new data.

Examples

Example: Using the CopyFromFile Method

This example demonstrates the use of the CopyFromFile method.

Be sure that you have the PART table in the database with valid LOB data in it. Also, be sure that you have installed the OraLOB Schema Objects as described in "Schema Objects Used in LOB Data Type Examples" .

Dim OraSession As OraSession 
Dim OraDatabase As OraDatabase 
Dim PartImage as OraBLOB 
 
'Create the OraSession Object. 
Set OraSession = CreateObject("OracleInProcServer.XOraSession") 
 
'Create the OraDatabase Object by opening a connection to Oracle. 
Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&)
 
'Create a Dynaset containing a BLOB and a CLOB column 
set part = OraDatabase.CreateDynaset ("select * from part where" & _
                "part_id = 1234",0) 
set PartImage = part.Fields("part_image").Value 
 
'copy the entire content of partimage.jpg file to LOBS 
part.Edit 
PartImage.CopyFromFile "partimage.jpg" 
part.Update