write method

Future<void> write(
  1. dynamic data, {
  2. int? offset,
})

Write data to the LOB

For CLOB/NCLOB, provide a String. For BLOB, provide a Uint8List or List<int>.

Parameters:

  • data: Data to write (String for CLOB/NCLOB, Uint8List for BLOB)
  • offset: Start position (1-based). If null, appends to end of LOB.

Implementation

Future<void> write(dynamic data, {int? offset}) async {
  _ensureNotDisposed();

  // If no offset specified, append to end of LOB
  final writeOffset = offset ?? (await size()) + 1;

  if (_lobType == LobType.blob) {
    if (data is! Uint8List && data is! List<int>) {
      throw OracleException(
        'BLOB write requires Uint8List or List<int>, got ${data.runtimeType}',
      );
    }
    await _writeBytes(data is Uint8List ? data : Uint8List.fromList(data), writeOffset);
  } else if (_lobType == LobType.clob || _lobType == LobType.nclob) {
    if (data is! String) {
      throw OracleException(
        'CLOB/NCLOB write requires String, got ${data.runtimeType}',
      );
    }
    await _writeString(data, writeOffset);
  } else {
    throw OracleException('Cannot write to BFILE LOB (read-only)');
  }

  // Clear cached size
  _cachedSize = null;
}