doPrepare method

void doPrepare()

Implementation

void doPrepare() {
  if (getSchemaType() == TSchemaType.stNoSchema) {
    _origSQL = _sql.text.trimRight();
  } else {
    _origSQL = database!.getSchemaInfoSQL(
        getSchemaType(), getSchemaObjectName(), getSchemaPattern());
  }
  if (_origSQL == '') {
    databaseError(SErrNoStatement);
  }
  _serverSQL = expandMacros(_origSQL);
  final sqlRef = TStringRef(_serverSQL);
  final stmInfo = getStatementInfo(sqlRef);
  _serverSQL = sqlRef.value;
  allocateCursor();
  _cursor!.fSelectable = true; // let PrepareStatement and/or Execute
  // alter it (original comment kept as-is)
  _cursor!.fStatementType = stmInfo.statementType;
  _cursor!.fSchemaType = getSchemaType();
  if (logEvent(TDBEventType.detPrepare)) {
    log(TDBEventType.detPrepare, _serverSQL);
  }
  database!.prepareStatement(_cursor!, transaction, _serverSQL, _params);
  // Update (original comment kept as-is)
  _cursor!.fInitFieldDef = _cursor!.fSelectable;
}