execute method Null safety

  1. @override
Future<int> execute(
  1. String fmtString,
  2. {Map<String, dynamic>? substitutionValues = const {},
  3. int? timeoutInSeconds}

Executes a query on this context.

This method sends a SQL string to the database this instance is connected to. Parameters can be provided in fmtString, see query for more details.

This method returns the number of rows affected and no additional information. This method uses the least efficient and less secure command for executing queries in the PostgreSQL protocol; query is preferred for queries that will be executed more than once, will contain user input, or return rows.


Future<int> execute(String fmtString,
    {Map<String, dynamic>? substitutionValues = const {},
    int? timeoutInSeconds}) async {
  timeoutInSeconds ??= _connection.queryTimeoutInSeconds;
  if (_connection.isClosed) {
    throw PostgreSQLException(
        'Attempting to execute query, but connection is not open.');

  final query = Query<void>(fmtString, substitutionValues, _connection,
      _transaction, StackTrace.current,
      onlyReturnAffectedRowCount: true);

  final result = await _enqueue(query, timeoutInSeconds: timeoutInSeconds);
  return result.affectedRowCount;