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
繼承
實作

備註

與不同之處OracleBFile在於,資料會儲存在伺服器上,而不是存放在作業系統的實體檔案中。 OracleLobAn 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上限為 4 gb 之二進位資料的 Oracle 資料類型。An Oracle BLOB data type that contains binary data with a maximum size of 4 gigabytes (GB). 這會對應至型別 ArrayByteThis maps to an Array of type Byte.
Clob Oracle CLOB資料類型,其中包含以伺服器上預設字元集為基礎的字元資料,大小上限為 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值抓取至基本Array的 .net 資料類型,例如和Byte String類型,或特製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 資料庫將 oracle LOB值抓取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. 如果LOB您將 Oracle 值抓取Array至或String類型Byte的,並更新這些陣列,您的變更就不會反映到資料庫中。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.

選取包含 null Null值的資料行就會傳回。LOBSelecting a LOB column that contains a null value returns Null.

您必須先開始交易,才能取得暫存LOBYou must begin a transaction before obtaining a temporary LOB. 否則, OracleDataReader稍後可能無法取得資料。Otherwise, the OracleDataReader may fail to obtain data later.

您也可以藉由呼叫LOB DBMS_LOB,在 Oracle 中開啟暫時的。CREATETEMPORARY 系統預存程式和LOB系結輸出參數。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. 藉由叫用來處置暫存LOBtempLob.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 是否支援寫入,永遠傳回 true。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

取得與基礎值對等的 Common Language Runtime 資料流值。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 物件,將相同的 Oracle LOB 參考為原始 OracleLob 物件。Creates 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)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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 的淺層複本 (Shallow Copy)。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()

傳回代表目前物件的字串。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)

適用於