size method

Future<int> size()

Get the size of the LOB in bytes (for BLOB/BFILE) or characters (for CLOB/NCLOB)

Implementation

Future<int> size() async {
  _ensureNotDisposed();

  if (_cachedSize != null) {
    return _cachedSize!;
  }

  final sizePtr = _memoryManager.allocate<Uint64>(sizeOf<Uint64>());
  final result = _dpiOracle.dpiLob_getSize(_lobPtr, sizePtr);

  if (result == DPI_FAILURE) {
    final errorInfo = _memoryManager.allocate<dpiErrorInfo>(sizeOf<dpiErrorInfo>());
    _dpiOracle.dpiContext_getError(_context, errorInfo);
    final errorMsg = StringUtils.fromNativeUtf8(errorInfo.ref.message.cast<Char>());

    throw OracleException(
      'Failed to get LOB size',
      errorMessage: errorMsg,
    );
  }

  _cachedSize = sizePtr.value;
  return _cachedSize!;
}