|
|
|
@ -338,8 +338,10 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
}
|
|
|
|
|
if (obj)
|
|
|
|
|
if (obj) {
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chan)
|
|
|
|
|
ast_autoservice_stop(chan);
|
|
|
|
@ -443,6 +445,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
|
|
|
|
|
ast_log(LOG_ERROR, "Unable to execute query [%s]\n", ast_str_buffer(sql));
|
|
|
|
|
if (obj) {
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
}
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
|
|
|
|
|
if (chan) {
|
|
|
|
@ -460,6 +463,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
|
|
|
|
|
if (chan) {
|
|
|
|
|
ast_autoservice_stop(chan);
|
|
|
|
@ -486,6 +490,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
|
|
|
|
|
if (chan)
|
|
|
|
@ -528,6 +533,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", "MEMERROR");
|
|
|
|
|
if (chan)
|
|
|
|
@ -625,6 +631,7 @@ end_acf_read:
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
if (chan)
|
|
|
|
|
ast_autoservice_stop(chan);
|
|
|
|
|
if (bogus_chan)
|
|
|
|
@ -637,6 +644,7 @@ end_acf_read:
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
if (chan)
|
|
|
|
|
ast_autoservice_stop(chan);
|
|
|
|
|
if (bogus_chan)
|
|
|
|
@ -1056,6 +1064,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|
|
|
|
ast_debug(1, "Got obj\n");
|
|
|
|
|
if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1067,6 +1076,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
AST_RWLIST_UNLOCK(&queries);
|
|
|
|
|
return CLI_SUCCESS;
|
|
|
|
|
}
|
|
|
|
@ -1076,6 +1086,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
if (res == SQL_NO_DATA) {
|
|
|
|
|
ast_cli(a->fd, "Returned %d rows. Query executed on handle %d:%s [%s]\n", rows, dsn, query->readhandle[dsn], ast_str_buffer(sql));
|
|
|
|
|
break;
|
|
|
|
@ -1103,27 +1114,33 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
AST_RWLIST_UNLOCK(&queries);
|
|
|
|
|
return CLI_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ast_cli(a->fd, "%-20.20s %s\n", colname, ast_str_buffer(coldata));
|
|
|
|
|
}
|
|
|
|
|
rows++;
|
|
|
|
|
|
|
|
|
|
/* Get next row */
|
|
|
|
|
res = SQLFetch(stmt);
|
|
|
|
|
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ast_cli(a->fd, "%-20.20s %s\n", "----------", "----------");
|
|
|
|
|
rows++;
|
|
|
|
|
}
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
ast_cli(a->fd, "Returned %d rows. Query executed on handle %d [%s]\n", rows, dsn, query->readhandle[dsn]);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
ast_cli(a->fd, "Returned %d row%s. Query executed on handle %d [%s]\n", rows, rows == 1 ? "" : "s", dsn, query->readhandle[dsn]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
if (obj) {
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!executed) {
|
|
|
|
|
ast_cli(a->fd, "Failed to execute query. [%s]\n", ast_str_buffer(sql));
|
|
|
|
@ -1252,6 +1269,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
|
|
|
|
|
}
|
|
|
|
|
if (!(stmt = ast_odbc_direct_execute(obj, generic_execute, ast_str_buffer(sql)))) {
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1259,6 +1277,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
|
|
|
|
|
SQLCloseCursor(stmt);
|
|
|
|
|
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
|
|
|
ast_odbc_release_obj(obj);
|
|
|
|
|
obj = NULL;
|
|
|
|
|
ast_cli(a->fd, "Affected %d rows. Query executed on handle %d [%s]\n", (int)rows, dsn, query->writehandle[dsn]);
|
|
|
|
|
executed = 1;
|
|
|
|
|
break;
|
|
|
|
|