SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql,
switch_core_db_callback_func_t callback, void *pdata, char **err);
+/*!
+ \brief Get the affected rows of the last performed query
+ \param [in] dbh The handle
+ \param [out] the number of affected rows
+*/
+SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh);
+
/*!
\brief Provides some feedback as to the status of the db connection pool
\param [in] stream stream for status
SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, switch_odbc_statement_handle_t stmt);
+
+SWITCH_DECLARE(int) switch_odbc_handle_affected_rows(switch_odbc_handle_t *handle);
+
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
bool release();
bool connected();
bool query(char *sql, SWIGLUA_FN lua_fun);
+ int affected_rows();
};
}
}
return false;
}
+
+int Dbh::affected_rows()
+{
+ if (m_connected) {
+ return switch_cache_db_affected_rows(dbh);
+ }
+ return 0;
+}
bool release();
bool connected();
bool query(char *sql, SWIGLUA_FN lua_fun);
+ int affected_rows();
};
}
#endif
}
+static int _wrap_Dbh_affected_rows(lua_State* L) {
+ int SWIG_arg = -1;
+ LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
+ int result;
+
+ SWIG_check_num_args("affected_rows",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("affected_rows",1,"LUA::Dbh *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
+ SWIG_fail_ptr("Dbh_affected_rows",1,SWIGTYPE_p_LUA__Dbh);
+ }
+
+ result = (int)(arg1)->affected_rows();
+ SWIG_arg=0;
+ lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+ return SWIG_arg;
+
+ if(0) SWIG_fail;
+
+fail:
+ lua_error(L);
+ return SWIG_arg;
+}
+
+
static void swig_delete_Dbh(void *obj) {
LUA::Dbh *arg1 = (LUA::Dbh *) obj;
delete arg1;
{"release", _wrap_Dbh_release},
{"connected", _wrap_Dbh_connected},
{"query", _wrap_Dbh_query},
+ {"affected_rows", _wrap_Dbh_affected_rows},
{0,0}
};
static swig_lua_attribute swig_LUA_Dbh_attributes[] = {
}
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_affected_rows(void * jarg1) {
+ int jresult ;
+ switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ;
+ int result;
+
+ arg1 = (switch_cache_db_handle_t *)jarg1;
+ result = (int)switch_cache_db_affected_rows(arg1);
+ jresult = result;
+ return jresult;
+}
+
+
SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_status(void * jarg1) {
switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ;
return ret;
}
+ public static int switch_cache_db_affected_rows(switch_cache_db_handle_t dbh) {
+ int ret = freeswitchPINVOKE.switch_cache_db_affected_rows(switch_cache_db_handle_t.getCPtr(dbh));
+ return ret;
+ }
+
public static void switch_cache_db_status(switch_stream_handle stream) {
freeswitchPINVOKE.switch_cache_db_status(switch_stream_handle.getCPtr(stream));
}
[DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_execute_sql_callback")]
public static extern int switch_cache_db_execute_sql_callback(HandleRef jarg1, string jarg2, HandleRef jarg3, HandleRef jarg4, ref string jarg5);
+ [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_affected_rows")]
+ public static extern int switch_cache_db_affected_rows(HandleRef jarg1);
+
[DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_status")]
public static extern void switch_cache_db_status(HandleRef jarg1);
SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu");
SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API");
SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t");
- /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
+ /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI);
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP)));
SvREADONLY_on(sv);
} while(0) /*@SWIG@*/;
- /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
+ /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI);
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE)));
SvREADONLY_on(sv);
} while(0) /*@SWIG@*/;
- /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
+ /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do {
SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI);
sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK)));
SvREADONLY_on(sv);
}
+SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)
+{
+ switch (dbh->type) {
+ case SCDB_TYPE_CORE_DB:
+ {
+ return switch_core_db_changes(dbh->native_handle.core_db_dbh);
+ }
+ break;
+ case SCDB_TYPE_ODBC:
+ {
+ return switch_odbc_handle_affected_rows(dbh->native_handle.odbc_dbh);
+ }
+ break;
+ }
+ return 0;
+}
+
+
SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_odbc_state_t state;
char odbc_driver[256];
BOOL is_firebird;
+ int affected_rows;
};
#endif
new_handle->env = SQL_NULL_HANDLE;
new_handle->state = SWITCH_ODBC_STATE_INIT;
+ new_handle->affected_rows = 0;
return new_handle;
SQLCHAR name[1024];
SQLLEN m = 0;
+ handle->affected_rows = 0;
+
if (switch_odbc_handle_exec(handle, sql, &stmt, err) == SWITCH_ODBC_SUCCESS) {
SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
SQLULEN ColumnSize;
int result;
SQLRowCount(stmt, &m);
+ handle->affected_rows = (int) m;
if (m <= 0) {
goto done;
SQLHSTMT stmt = NULL;
int result;
char *err_str = NULL;
+ SQLLEN m = 0;
+
+ handle->affected_rows = 0;
if (!db_is_up(handle)) {
goto error;
goto error;
}
+ SQLRowCount(stmt, &m);
+ handle->affected_rows = (int) m;
+
if (rstmt) {
*rstmt = stmt;
} else {
int err_cnt = 0;
int done = 0;
+ handle->affected_rows = 0;
+
switch_assert(callback != NULL);
if (!db_is_up(handle)) {
SQLNumResultCols(stmt, &c);
SQLRowCount(stmt, &m);
+ handle->affected_rows = (int) m;
while (!done) {
#endif
}
+SWITCH_DECLARE(int) switch_odbc_handle_affected_rows(switch_odbc_handle_t *handle)
+{
+#ifdef SWITCH_HAVE_ODBC
+ return handle->affected_rows;
+#else
+ return 0;
+#endif
+}
+
SWITCH_DECLARE(switch_bool_t) switch_odbc_available(void)
{
#ifdef SWITCH_HAVE_ODBC