OracleLob.Write(Byte[], Int32, Int32) 메서드

정의

현재 OracleLob 스트림에 바이트 시퀀스를 쓰고 이 스트림 내의 현재 위치를 기록된 바이트 수만큼 앞으로 이동합니다.

public:
 override void Write(cli::array <System::Byte> ^ buffer, int offset, int count);
public override void Write(byte[] buffer, int offset, int count);
override this.Write : byte[] * int * int -> unit
Public Overrides Sub Write (buffer As Byte(), offset As Integer, count As Integer)

매개 변수

buffer
Byte[]

바이트 배열입니다. 이 메서드는 현재 스트림에서 count 지정된 buffer 바이트 수를 복사합니다.

offset
Int32

현재 스트림에 바이트 복사를 시작할 바이트 오프셋 buffer (0부터 시작)입니다. 데이터 형식의 CLOB 경우 NCLOB 짝수여야 합니다.

count
Int32

현재 스트림에 쓸 바이트 수입니다. 데이터 형식의 CLOB 경우 NCLOB 짝수여야 합니다.

예외

buffer 매개 변수는 null 참조입니다(Visual Basic Nothing).

또는 offset 매개 변수의 count 값이 양수가 아닙니다.

-또는-

offset 매개 변수의 count 합계가 길이보다 buffer 큽다.

-또는-

또는 매개 변수에 count 지정된 값이 0보다 작거나 offset 4GB보다 큽니다.

-또는-

데이터 형식을 CLOB 짝수 바이트로 지정 NCLOB 해야 합니다.

작업이 트랜잭션 내에 없거나, 개체가 OracleLob null이거나, 연결이 닫힙니다.

개체를 닫거나 삭제했습니다.

Oracle 오류가 발생했습니다.

설명

쓰기 작업이 성공하면 스트림 내의 위치가 기록된 바이트 수만큼 이동합니다. 예외가 발생하면 스트림 내의 위치는 변경되지 않은 상태로 유지됩니다.

LOB 부분에 대한 쓰기는 허용되며 기록된 LOB 바이트 수만큼 확대됩니다.

Oracle용 .NET Framework Data Provider 모든 CLOBNCLOB 데이터를 유니코드로 처리합니다. 따라서 액세스 CLOBNCLOB 데이터 형식의 경우 항상 각 문자가 2바이트인 바이트 수를 처리합니다. 예를 들어 문자 집합이 문자당 4바이트인 Oracle 서버에 세 문자가 포함된 텍스트 문자열을 저장 NCLOB 하고 작업을 수행하는 Write 경우 문자열 길이를 6바이트로 지정합니다. 단, 문자열 길이는 서버에 12바이트로 저장됩니다.

에 쓰 LOB려면 SQL SELECT 문에서 FOR UPDATE 절을 사용하여 검색 LOB 해야 하며 로컬 트랜잭션이 시작되어야 합니다.

다음 예제에서는 개체에 OracleLob 쓰는 방법을 보여 줍니다.

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).
        var 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 읽기 작업은 쓰기 작업의 결과를 반환할 수 있습니다.

적용 대상