------------------------------------------------------------------------------
| 167 | |
| 168 | //------------------------------------------------------------------------------ |
| 169 | bool vtkSQLiteQuery::Execute() |
| 170 | { |
| 171 | |
| 172 | if (this->Query == nullptr) |
| 173 | { |
| 174 | vtkErrorMacro(<< "Cannot execute before a query has been set."); |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | if (this->Private->Statement == nullptr) |
| 179 | { |
| 180 | vtkErrorMacro(<< "Execute(): Query is not null but prepared statement is. There may have been " |
| 181 | "an error during SetQuery()."); |
| 182 | this->Active = false; |
| 183 | return false; |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | sqlite3_reset(this->Private->Statement); |
| 188 | } |
| 189 | |
| 190 | vtkDebugMacro(<< "Execute(): Query ready to execute."); |
| 191 | |
| 192 | this->InitialFetch = true; |
| 193 | int result = sqlite3_step(this->Private->Statement); |
| 194 | this->InitialFetchResult = result; |
| 195 | |
| 196 | if (result == SQLITE_DONE) |
| 197 | { |
| 198 | this->SetLastErrorText(nullptr); |
| 199 | this->Active = true; |
| 200 | return true; |
| 201 | } |
| 202 | else if (result != SQLITE_ROW) |
| 203 | { |
| 204 | vtkSQLiteDatabase* dbContainer = vtkSQLiteDatabase::SafeDownCast(this->Database); |
| 205 | assert(dbContainer != nullptr); |
| 206 | |
| 207 | sqlite3* db = dbContainer->Internal->SQLiteInstance; |
| 208 | |
| 209 | this->SetLastErrorText(sqlite3_errmsg(db)); |
| 210 | vtkDebugMacro(<< "Execute(): sqlite3_step() returned error message " |
| 211 | << this->GetLastErrorText()); |
| 212 | this->Active = false; |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | this->SetLastErrorText(nullptr); |
| 217 | this->Active = true; |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | //------------------------------------------------------------------------------ |
| 222 | int vtkSQLiteQuery::GetNumberOfFields() |