OracleLob.Write メソッド
アセンブリ: System.Data.OracleClient (system.data.oracleclient.dll 内)

Dim instance As OracleLob Dim buffer As Byte() Dim offset As Integer Dim count As Integer instance.Write(buffer, offset, count)

例外の種類 | 条件 |
---|---|
ArgumentNullException | buffer パラメータが null 参照 (Visual Basic の場合は Nothing) です。 |
ArgumentOutOfRangeException | offset パラメータまたは count パラメータの値が正の値ではありません。 または offset パラメータと count パラメータの合計値が、buffer の長さを超えています。 または count パラメータまたは offset パラメータに指定された値が 0 より小さいか、4 GB を超えています。 または |
InvalidOperationException | 操作がトランザクション内で実行されていないか、OracleLob オブジェクトが null か、または接続が閉じられています。 |
ObjectDisposedException | |
OracleException |

書き込み操作が成功した場合は、書き込まれたバイト数だけストリーム内の位置が進みます。例外が発生した場合は、ストリーム内の位置はそのまま変わりません。
LOB の末尾を超えて書き込むことができます。その場合、LOB は、書き込んだバイト数だけ拡大されます。
.NET Framework Oracle 用データ プロバイダは、すべての CLOB データおよび NCLOB データを Unicode として処理します。したがって、CLOB 型および NCLOB 型では 1 文字が 2 バイトとなるため、これらにアクセスするときは常に複数のバイトを扱うことになります。たとえば、3 文字から成る文字列が、1 文字が 4 バイトの文字セットを使用している Oracle サーバーに NCLOB として保存されていて、Write 操作を実行する場合、文字列はサーバーに 12 バイトとして格納されていますが、文字列の長さは 6 バイトを指定します。
LOB に書き込むには、SQL SELECT ステートメントで FOR UPDATE 句を使用して LOB を取得する必要があり、さらにローカル トランザクションが開始している必要があります。
OracleLob オブジェクトに書き込む方法の C# の例を次に示します。
public static void WriteLobExample(OracleCommand command) { //Note: Updating LOB data requires a transaction. command.Transaction = command.Connection.BeginTransaction(); //Select some data. // Table Schema: // "CREATE TABLE tablewithlobs (a int, b BLOB, c BLOB)"; // "INSERT INTO tablewithlobs values (1, 'AA', 'AAA')"; command.CommandText = "SELECT * FROM TableWithLobs FOR UPDATE"; OracleDataReader reader = command.ExecuteReader(); using(reader) { //Obtain the first row of data. reader.Read(); //Obtain both LOBs. OracleLob BLOB1 = reader.GetOracleLob(1); OracleLob BLOB2 = reader.GetOracleLob(2); //Perform any desired operations on the LOB, (read, position, and so on). //... //Example - Writing binary data (directly to the backend). //To write, you can use any of the stream classes, or write raw binary data using //the OracleLob write method. Writing character vs. binary is the same; //however note that character is always in terms of Unicode byte counts //(for example: even number of bytes - 2 bytes for every Unicode character). byte[] buffer = new byte[100]; buffer[0] = 0xCC; buffer[1] = 0xDD; BLOB1.Write(buffer, 0, 2); BLOB1.Position = 0; Console.WriteLine(BLOB1.LobType + ".Write(" + buffer + ", 0, 2) => " + BLOB1.Value); //Example - Copying data into another LOB. long actual = BLOB1.CopyTo(BLOB2); Console.WriteLine(BLOB1.LobType + ".CopyTo(" + BLOB2.Value + ") => " + actual); //Commit the transaction now that everything succeeded. //Note: On error, Transaction.Dispose is called (from the using statement) //and will automatically roll-back the pending transaction. command.Transaction.Commit(); } }
![]() |
---|
読み取り専用の LOB に対する書き込み操作が成功する可能性がありますが、サーバー上の LOB は更新されません。ただし、この場合、LOB のローカル コピーは更新されます。したがって、OracleLob オブジェクトに対するその後の読み取り操作では、書き込み操作の結果が返される可能性があります。 |

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からOracleLob.Write メソッドを検索する場合は、下記のリンクをクリックしてください。

- OracleLob.Write メソッドのページへのリンク