| 839 | } |
| 840 | |
| 841 | void SqliteSampleBlock::Delete() |
| 842 | { |
| 843 | auto db = DB(); |
| 844 | int rc; |
| 845 | |
| 846 | wxASSERT(!IsSilent()); |
| 847 | |
| 848 | // Prepare and cache statement...automatically finalized at DB close |
| 849 | sqlite3_stmt *stmt = Conn()->Prepare(DBConnection::DeleteSampleBlock, |
| 850 | "DELETE FROM sampleblocks WHERE blockid = ?1;"); |
| 851 | |
| 852 | // Bind statement parameters |
| 853 | // Might return SQLITE_MISUSE which means it's our mistake that we violated |
| 854 | // preconditions; should return SQL_OK which is 0 |
| 855 | if (sqlite3_bind_int64(stmt, 1, mBlockID)) |
| 856 | { |
| 857 | ADD_EXCEPTION_CONTEXT( |
| 858 | "sqlite3.rc", std::to_string(sqlite3_errcode(Conn()->DB()))); |
| 859 | ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::bind"); |
| 860 | |
| 861 | wxASSERT_MSG(false, wxT("Binding failed...bug!!!")); |
| 862 | } |
| 863 | |
| 864 | // Execute the statement |
| 865 | rc = sqlite3_step(stmt); |
| 866 | if (rc != SQLITE_DONE) |
| 867 | { |
| 868 | ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc)); |
| 869 | ADD_EXCEPTION_CONTEXT("sqlite3.context", "SqliteSampleBlock::Delete::step"); |
| 870 | |
| 871 | wxLogDebug(wxT("SqliteSampleBlock::Load - SQLITE error %s"), sqlite3_errmsg(db)); |
| 872 | |
| 873 | // Clear statement bindings and rewind statement |
| 874 | sqlite3_clear_bindings(stmt); |
| 875 | sqlite3_reset(stmt); |
| 876 | |
| 877 | // Just showing the user a simple message, not the library error too |
| 878 | // which isn't internationalized |
| 879 | Conn()->ThrowException( true ); |
| 880 | } |
| 881 | |
| 882 | // Clear statement bindings and rewind statement |
| 883 | sqlite3_clear_bindings(stmt); |
| 884 | sqlite3_reset(stmt); |
| 885 | } |
| 886 | |
| 887 | void SqliteSampleBlock::SaveXML(XMLWriter &xmlFile) |
| 888 | { |
nothing calls this directly
no test coverage detected