OracleLob 类

定义

表示存储在 Oracle 服务器上的大型对象二进制 (LOB) 数据类型。Represents a large object binary (LOB) data type stored on an Oracle server. 此类不能被继承。This class cannot be inherited.

public ref class OracleLob sealed : System::IO::Stream, ICloneable, System::Data::SqlTypes::INullable
public sealed class OracleLob : System.IO.Stream, ICloneable, System.Data.SqlTypes.INullable
type OracleLob = class
    inherit Stream
    interface ICloneable
    interface IDisposable
    interface INullable
Public NotInheritable Class OracleLob
Inherits Stream
Implements ICloneable, INullable
继承
实现

注解

OracleLob与的OracleBFile不同之处在于,数据存储在服务器上而不是存储在操作系统的物理文件中。An OracleLob differs from an OracleBFile in that the data is stored on the server instead of in a physical file in the operating system. 它也可以是读写对象,这一点与始终OracleBFile是只读对象不同。It can also be a read-write object, unlike an OracleBFile, which is always read-only.

可以是下列OracleType数据类型之一。 OracleLobAn OracleLob may be one of these OracleType data types.

OracleType 数据类型OracleType data type 说明Description
Blob 一种BLOB Oracle 数据类型,它包含最大大小为 4 gb 的二进制数据。An Oracle BLOB data type that contains binary data with a maximum size of 4 gigabytes (GB). 它映射到 Array 类型的 ByteThis maps to an Array of type Byte.
Clob 包含字符CLOB数据的 Oracle 数据类型,它基于服务器上的默认字符集,最大大小为 4 GB。An Oracle CLOB data type that contains character data, based on the default character set on the server, with a maximum size of 4 GB. 它映射到 StringThis maps to String.
NClob 包含字符NCLOB数据的 Oracle 数据类型,其最大大小为 4 GB,基于服务器上的区域字符集。An Oracle NCLOB data type that contains character data, based on the national character set on the server with a maximum size of 4 GB. 它映射到 StringThis maps to String.

.Net 应用程序开发人员可以将 Oracle LOB值检索到基本 .net 数据类型中, Array如类型ByteString或专用OracleLob数据类型。A .NET application developer can retrieve the Oracle LOB values into basic .NET data types, such as Array of type Byte and String, or the specialized OracleLob data type. 类支持在 oracle 数据库中读取和写入 oracle LOB数据库中的数据。 OracleLobThe OracleLob class supports reading data from and writing to the Oracle LOB in the Oracle database.

以下是将OracleLob数据与基本 .net 数据类型区分开来的数据类型的主要特征:The following are the main characteristics of an OracleLob data type that distinguish it from basic .NET data types:

  • 将 oracle 数据库中的LOB oracle 值检索OracleLob到类中后,你可以更改打开的LOB事务中的数据,所做的更改将直接反映到数据库中。After you retrieve the Oracle LOB value from the Oracle database into the OracleLob class, you can change the LOB data in an open transaction and your changes are directly reflected to the database. 如果将 Oracle LOB值检索Array到类型Byte为的或String并更新这些数组,则所做的更改不会反映到数据库中。If you retrieve the Oracle LOB value into an Array of type Byte or String and update these arrays, your changes are not reflected to the database.

  • 使用OracleLob类访问某个LOB值块区时,仅将该区块从 Oracle 数据库传递到客户端。When you use the OracleLob class to access a chunk of a LOB value, only that chunk is passed from the Oracle database to the client. 使用GetChars方法访问某个LOB值块区时,会将此值的所有内容从 Oracle 数据库传递到客户端。When you use the GetChars method to access a chunk of a LOB value, the entire contents of the value are passed from the Oracle database to the client.

若要获取OracleLob对象,请GetOracleLob调用方法。To obtain an OracleLob object, call the GetOracleLob method.

可以使用以下格式OracleLob构造一个为 NULL 的:You can construct an OracleLob that is NULL using this format:

OracleLob myLob = OracleLob.Null;  

此方法主要用于测试从服务器返回的LOB是否为 NULL,如本示例所示:This technique is used primarily to test whether a LOB returned from the server is NULL, as this example illustrates:

If(myLob == OracleLob.Null)  

NULL LOB的行为类似于中的零字节LOB ,这Read会成功并且始终返回零字节。A NULL LOB behaves similarly to a zero-byte LOB in that Read succeeds and always returns zero bytes.

选择包含LOB null 值的列时,将Null返回。Selecting a LOB column that contains a null value returns Null.

在获取临时LOB之前,必须先开始事务。You must begin a transaction before obtaining a temporary LOB. 否则,可能OracleDataReader无法在以后获取数据。Otherwise, the OracleDataReader may fail to obtain data later.

还可以通过调用 DBMS_LOB 在LOB Oracle 中打开一个临时项。CREATETEMPORARY 系统存储过程并绑定LOB output 参数。You can also open a temporary LOB in Oracle by calling the DBMS_LOB.CREATETEMPORARY system stored procedure and binding a LOB output parameter. 在客户端,临时LOB的行为类似于表。 LOBOn the client side, a temporary LOB behaves like a table-based LOB. 例如,若要更新临时LOB,则必须将其包含在事务中。For example, to update the temporary LOB, it must be enclosed in a transaction.

下面C#的示例演示如何打开一个临时LOB的。The following C# example demonstrates how to open a temporary LOB.

OracleConnection connection = new OracleConnection("server=MyServer; integrated security=yes;");  
connection.Open();  
OracleTransaction transaction = connection.BeginTransaction();  
OracleCommand command = connection.CreateCommand();  
command.Transaction = transaction;  
command.CommandText = "declare xx blob; begin dbms_lob.createtemporary(xx, false, 0); :tempblob := xx; end;";  
command.Parameters.Add(new OracleParameter("tempblob", OracleType.Blob)).Direction = ParameterDirection.Output;  
command.ExecuteNonQuery();  
OracleLob tempLob = (OracleLob)command.Parameters[0].Value;  
byte[] tempbuff = new byte[10000];  
tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);  
tempLob.Write(tempbuff,0,tempbuff.Length);  
tempLob.EndBatch();  
command.Parameters.Clear();  
command.CommandText = "MyTable.MyProc";  
command.CommandType = CommandType.StoredProcedure;    
command.Parameters.Add(new OracleParameter("ImportDoc", OracleType.Blob)).Value = tempLob;  
command.ExecuteNonQuery();  
transaction.Commit();  
connection.Close  

备注

如果与WriteByte字符数据一起使用,则继承的方法将InvalidOperationException失败,并且会引发。The inherited WriteByte method fails if used with character data, and an InvalidOperationException is thrown. 请改用 Write 方法。Use the Write method instead.

LOB当关闭连接时才关闭临时,但在加载时,临时LOB不会关闭。Temporary LOBs are only closed when the connection is closed, but with pooling and under load, temporary LOBs do not close. 这可以通过调用LOB tempLob.Dispose()来释放临时的来解决。This can be resolved by disposing the temporary LOB, by invoking tempLob.Dispose().

字段

Null

表示一个 null OracleLob 对象。Represents a null OracleLob object.

属性

CanRead

获取一个值,该值指示 LOB 流是否可读。Gets a value indicating whether the LOB stream can be read.

CanSeek

获取一个值,该值指示能否执行向前和向后查找操作。Gets a value indicating whether forward and backward seek operations can be performed.

CanTimeout

获取一个值,该值确定当前流是否可以超时。Gets a value that determines whether the current stream can time out.

(继承自 Stream)
CanWrite

不管 LOB 是否支持写入,始终返回真。Always returns true, regardless of whether the LOB supports writing or not.

ChunkSize

获取一个值,该值指示读/写操作过程中要从服务器检索或发送到服务器的最小字节数。Gets a value indicating the minimum number of bytes to retrieve from or send to the server during a read/write operation.

Connection

获取由该 OracleConnection 实例使用的 OracleLobGets the OracleConnection used by this instance of the OracleLob.

IsBatched

获取一个值,该值指示应用程序是否调用了 BeginBatch() 方法。Gets a value indicating whether an application called the BeginBatch() method.

IsNull

获取一个值,该值指示 OracleLob 是否为一个 Null 流。Gets a value that indicates whether the OracleLob is a Null stream.

IsTemporary

获取一个值,该值指示 OracleLob 是否为临时 LOBGets a value indicating whether the OracleLob is a temporary LOB.

Length

获取一个值,该值返回 OracleLob 的大小。Gets a value that returns the size of the OracleLob.

LobType

获取一个值,该值返回 LOB 数据类型。Gets a value that returns the LOB data type.

Position

获取 OracleLob 流中的当前读取位置。Gets the current read position in the OracleLob stream.

ReadTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试读取多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

(继承自 Stream)
Value

获取公共语言运行时流值(基础值的等效值)。Gets the common language runtime stream value equivalent of the underlying value.

WriteTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试写入多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

(继承自 Stream)

方法

Append(OracleLob)

将数据从指定的 LOB 追加到当前 LOBAppends data from the specified LOB to the current LOB.

BeginBatch()

在执行多个读操作时避免服务器端触发器激发。Prevents server-side triggers from firing while performing multiple read operations.

BeginBatch(OracleLobOpenMode)

在以指定的访问模式执行多个读写操作时避免服务器端触发器激发。Prevents server-side triggers from firing while performing multiple read and write operations in the specified access mode.

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步读操作。Begins an asynchronous read operation. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步写操作。Begins an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
Clone()

创建一个新 OracleLob 对象,该对象与原始 OracleLob 对象引用相同的 Oracle LOBCreates a new OracleLob object that references the same Oracle LOB as the original OracleLob object.

Close()

关闭当前流并释放与该流关联的资源。Closes the current stream and releases resources that are associated with the stream.

CopyTo(Int64, OracleLob, Int64, Int64)

使用该源偏移量将指定数量的数据从该 OracleLob 复制到目标 OracleLobCopies from this OracleLob to a destination OracleLob with the specified amount of data, and the source offset.

CopyTo(OracleLob)

从该 OracleLob 复制到目标 OracleLobCopies from this OracleLob to a destination OracleLob.

CopyTo(OracleLob, Int64)

将指定数量的数据从该 OracleLob 复制到目标 OracleLobCopies from this OracleLob to a destination OracleLob with the specified amount of data.

CopyTo(Stream)

从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream.

(继承自 Stream)
CopyTo(Stream, Int32)

使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(继承自 Stream)
CopyToAsync(Stream)

从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream.

(继承自 Stream)
CopyToAsync(Stream, CancellationToken)

通过指定的取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.

(继承自 Stream)
CopyToAsync(Stream, Int32)

使用指定的缓冲区大小,从当前流中异步读取字节并将其写入到另一流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(继承自 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

使用指定的缓冲区大小和取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

(继承自 Stream)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
CreateWaitHandle()

分配 WaitHandle 对象。Allocates a WaitHandle object.

(继承自 Stream)
Dispose()

释放此对象使用的资源。Releases the resources that are used by this object.

Dispose(Boolean)

释放由 Stream 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

(继承自 Stream)
DisposeAsync()

异步释放 Stream 使用的非托管资源。Asynchronously releases the unmanaged resources used by the Stream.

(继承自 Stream)
EndBatch()

允许服务器端触发器在执行多个写入操作之后继续激发。Allows server-side triggers to resume firing after performing multiple write operations.

EndRead(IAsyncResult)

等待挂起的异步读取完成。Waits for the pending asynchronous read to complete. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
EndWrite(IAsyncResult)

结束异步写操作。Ends an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Erase()

从该 OracleLob 清除所有数据。Erases all data from this OracleLob.

Erase(Int64, Int64)

从该 OracleLob 清除指定数量的数据。Erases the specified amount of data from this OracleLob.

Flush()

目前尚不支持。Not currently supported.

FlushAsync()

异步清除此流的所有缓冲区并导致所有缓冲数据都写入基础设备中。Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

(继承自 Stream)
FlushAsync(CancellationToken)

异步清理这个流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

(继承自 Stream)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ObjectInvariant()

提供对 Contract 的支持。Provides support for a Contract.

(继承自 Stream)
Read(Byte[], Int32, Int32)

从当前 OracleLob 流中读取字节序列,并在该流中按照读取的字节数提升位置。Reads a sequence of bytes from the current OracleLob stream and advances the position within the stream by the number of bytes read.

Read(Span<Byte>)

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

(继承自 Stream)
ReadAsync(Byte[], Int32, Int32)

从当前流异步读取字节序列,并将流中的位置提升读取的字节数。Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

(继承自 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

(继承自 Stream)
ReadAsync(Memory<Byte>, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

(继承自 Stream)
ReadByte()

从流中读取一个字节,并将流内的位置向前提升一个字节,或者如果已到达流结尾,则返回 -1。Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

(继承自 Stream)
Seek(Int64, SeekOrigin)

在当前 OracleLob 流上设置位置。Sets the position on the current OracleLob stream.

SetLength(Int64)

OracleLob 流的长度设置为小于当前长度的值。Sets the length of the OracleLob stream to a value less than the current length.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
Write(Byte[], Int32, Int32)

将一个字节序列写入当前 OracleLob 流,并使流中的当前位置前进所写入的字节数。Writes a sequence of bytes to the current OracleLob stream, and advances the current position within this stream by the number of bytes written.

Write(ReadOnlySpan<Byte>)

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

(继承自 Stream)
WriteAsync(Byte[], Int32, Int32)

将字节序列异步写入当前流,并将流的当前位置提升写入的字节数。Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

(继承自 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

(继承自 Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

(继承自 Stream)
WriteByte(Byte)

将一个字节写入 OracleLob 流内的当前位置,并将流内的位置向前推进一个字节。Writes a byte to the current position in the OracleLob stream, and advances the position within the stream by one byte.

显式界面实现

IDisposable.Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

(继承自 Stream)

适用于