executeDirect method

void executeDirect(
  1. String sql, [
  2. TSQLTransaction? aTransaction
])

Implementation

void executeDirect(String sql, [TSQLTransaction? aTransaction]) {
  final trans = aTransaction ?? _sqlTransaction;
  if (trans == null) {
    databaseError(SErrTransactionnSet);
  }
  if (!connected) openConnection();
  if (!trans!.active) trans.maybeStartTransaction();

  var s = sql.trimRight();
  if (s == '') {
    databaseError(SErrNoStatement);
  }

  TSQLCursor? cursor;
  try {
    cursor = allocateCursorHandle();
    cursor.fStatementType = TStatementType.stUnknown;
    if (logEvent(TDBEventType.detPrepare)) {
      log(TDBEventType.detPrepare, s);
    }
    prepareStatement(cursor, trans, s, null);
    try {
      if (logEvent(TDBEventType.detExecute)) {
        log(TDBEventType.detExecute, s);
      }
      execute(cursor, trans, null);
    } finally {
      unPrepareStatement(cursor);
    }
  } finally {
    if (cursor != null) deAllocateCursorHandle(cursor);
  }
}