/ Execute a prepared statement. */ /
| 1759 | /* Execute a prepared statement. */ |
| 1760 | /***********************************************************************/ |
| 1761 | int ODBConn::ExecuteSQL(void) |
| 1762 | { |
| 1763 | PGLOBAL& g = m_G; |
| 1764 | SWORD ncol = 0; |
| 1765 | RETCODE rc; |
| 1766 | SQLLEN afrw = -1; |
| 1767 | |
| 1768 | try { |
| 1769 | do { |
| 1770 | rc = SQLExecute(m_hstmt); |
| 1771 | } while (rc == SQL_STILL_EXECUTING); |
| 1772 | |
| 1773 | if (!Check(rc)) |
| 1774 | ThrowDBX(rc, "SQLExecute", m_hstmt); |
| 1775 | |
| 1776 | if (!Check(rc = SQLNumResultCols(m_hstmt, &ncol))) |
| 1777 | ThrowDBX(rc, "SQLNumResultCols", m_hstmt); |
| 1778 | |
| 1779 | if (ncol) { |
| 1780 | // This should never happen while inserting |
| 1781 | snprintf(g->Message, sizeof(g->Message), "Logical error while inserting"); |
| 1782 | } else { |
| 1783 | // Insert, Update or Delete statement |
| 1784 | if (!Check(rc = SQLRowCount(m_hstmt, &afrw))) |
| 1785 | ThrowDBX(rc, "SQLRowCount", m_hstmt); |
| 1786 | |
| 1787 | } // endif ncol |
| 1788 | |
| 1789 | } catch(DBX *x) { |
| 1790 | snprintf(m_G->Message, sizeof(m_G->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0)); |
| 1791 | SQLCancel(m_hstmt); |
| 1792 | rc = SQLFreeStmt(m_hstmt, SQL_DROP); |
| 1793 | m_hstmt = NULL; |
| 1794 | |
| 1795 | if (m_Transact) { |
| 1796 | rc = SQLEndTran(SQL_HANDLE_DBC, m_hdbc, SQL_ROLLBACK); |
| 1797 | m_Transact = false; |
| 1798 | } // endif m_Transact |
| 1799 | |
| 1800 | afrw = -1; |
| 1801 | } // end try/catch |
| 1802 | |
| 1803 | return (int)afrw; |
| 1804 | } // end of ExecuteSQL |
| 1805 | |
| 1806 | /***********************************************************************/ |
| 1807 | /* Bind a parameter for inserting. */ |
nothing calls this directly
no test coverage detected