Inserting LOBs on Oracle server 8. Maximum capacity of a LOB is 4 gigabytes-1 bytes. In Oracle three kinds of LOB data type exist: BLOB datatype stores unstructured binary large objects.
BLOB objects can be thought of as bitstreams with no character set semantics. The CLOB datatype stores single-byte and multibyte character data. Both fixed-width and variable-width character sets are supported, and both use the database character set. Another issue you should be aware of is temporary LOBs.
This kind of object is not referenced by any table yet. It exists in current transaction only. You have to use temporary LOBs when inserting new data to a table. Once you create an OracleLob instance corresponding temporary LOB appears on the server, and any data you insert into the object is sent immediately to server.
An example of using temporary LOBs you will see later in the article. You can work with OracleLob. Value property or use OracleLob.
Write methods to transfer data to and from server. Both ways are presented in the samples below. Note that when OracleLob. LobType property is OracleDbType.
Value is treated as array of bytes byte , whereas OracleDbType. The next sample routines show how to upload a file from hard disk to server and download it back. To execute these routines you have to create a table that is described as follows: GetOrdinal "Picture" ; if!
Read b,0, int myLob. Write b,0, int myLob. Length 'Transfer data to server myLob. Default Try While myReader. Concat FN, " downloaded. The difference is in representation of Value property. Value property, you get strings.
The data is transparently decoded so you do not have to take care about its character set. If you need raw data however you can use streaming capabilities of OracleLob, that is OracleLob. Note that since OracleLob. Write method, and no encoding is performed. For example consider this table definition. In addition you can use OracleDataReader. GetBytes to get pieces of LOB value. ExecuteReader ; while reader. GetValue 2 end while You can do the same thing using OracleLob object directly. ExecuteReader ; OracleLob clob; while reader.
GetOracleLob 2 ; Console. As we see first code cut was shorter. So, usually, you need to access OracleLob directly in more complicated cases e. Value Here is the sample code: Add "Id", 1 ; oraCommand. Add "Id", 1 oraCommand. Stored procedures allow you to automate initialization process of LOB values as follows. At the same time set Direction property for parameter of Lob data type to ParameterDirection.
Input and assign it with required data prior to actual call to stored procedure. Having previous procedure declaration we may execute it as this: If Direction is ParameterDirection.