RTS API Documentation  1.10.11
switch_odbc.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  * switch_odbc.h -- ODBC
29  *
30  */
31 
32 #ifndef SWITCH_ODBC_H
33 #define SWITCH_ODBC_H
34 
35 #include <switch.h>
36 
37 #define DEFAULT_ODBC_RETRIES 120
38 
39 SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle;
40 typedef void *switch_odbc_statement_handle_t;
41 
42 typedef enum {
48 
49 typedef enum {
53 
55 SWITCH_DECLARE(switch_odbc_handle_t *) switch_odbc_handle_new(const char *dsn, const char *username, const char *password);
62  char **err);
63 SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err);
68 
69 /*!
70  \brief Execute the sql query and issue a callback for each row returned
71  \param file the file from which this function is called
72  \param func the function from which this function is called
73  \param line the line from which this function is called
74  \param handle the ODBC handle
75  \param sql the sql string to execute
76  \param callback the callback function to execute
77  \param pdata the state data passed on each callback invocation
78  \return SWITCH_STATUS_SUCCESS if the operation was successful
79  \note none
80 */
81 SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(const char *file, const char *func, int line, switch_odbc_handle_t *handle,
82  const char *sql, switch_core_db_callback_func_t callback, void *pdata,
83  char **err);
84 /*!
85  \brief Execute the sql query and issue a callback for each row returned
86  \param handle the ODBC handle
87  \param sql the sql string to execute
88  \param callback the callback function to execute
89  \param pdata the state data passed on each callback invocation
90  \return SWITCH_STATUS_SUCCESS if the operation was successful
91  \note none
92 */
93 #define switch_odbc_handle_callback_exec(handle, sql, callback, pdata, err) \
94  switch_odbc_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \
95  handle, sql, callback, pdata, err)
96 
97 
99 
101 
103 #endif
104 /* For Emacs:
105  * Local Variables:
106  * mode:c
107  * indent-tabs-mode:t
108  * tab-width:4
109  * c-basic-offset:4
110  * End:
111  * For VIM:
112  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
113  */
switch_odbc_status_t switch_odbc_handle_exec_string(switch_odbc_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err)
Definition: switch_odbc.c:412
switch_odbc_status_t
Definition: switch_odbc.h:49
switch_odbc_state_t
Definition: switch_odbc.h:42
struct switch_odbc_handle switch_odbc_handle_t
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
int switch_odbc_handle_affected_rows(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:800
switch_bool_t
Definition: switch_types.h:437
void switch_odbc_handle_destroy(switch_odbc_handle_t **handlep)
Definition: switch_odbc.c:742
switch_odbc_status_t switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err)
Definition: switch_odbc.c:456
switch_odbc_status_t switch_odbc_statement_handle_free(switch_odbc_statement_handle_t *stmt)
Definition: switch_odbc.c:328
switch_odbc_state_t switch_odbc_handle_get_state(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:771
switch_bool_t switch_odbc_available(void)
Definition: switch_odbc.c:809
int(* switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames)
void switch_odbc_set_num_retries(switch_odbc_handle_t *handle, int num_retries)
Definition: switch_odbc.c:117
void switch_odbc_skip_autocommit_flip(void)
Definition: switch_odbc.c:67
switch_odbc_status_t switch_odbc_handle_connect(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:343
Main Library Header.
#define SWITCH_DECLARE(type)
switch_odbc_status_t switch_odbc_SQLEndTran(switch_odbc_handle_t *handle, switch_bool_t commit)
Definition: switch_odbc.c:835
char * switch_odbc_handle_get_error(switch_odbc_handle_t *handle, switch_odbc_statement_handle_t stmt)
Definition: switch_odbc.c:780
void * switch_odbc_statement_handle_t
Definition: switch_odbc.h:39
switch_odbc_handle_t * switch_odbc_handle_new(const char *dsn, const char *username, const char *password)
Definition: switch_odbc.c:72
switch_odbc_status_t switch_odbc_SQLSetAutoCommitAttr(switch_odbc_handle_t *handle, switch_bool_t on)
Definition: switch_odbc.c:818
switch_odbc_status_t switch_odbc_handle_callback_exec_detailed(const char *file, const char *func, int line, switch_odbc_handle_t *handle, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
Execute the sql query and issue a callback for each row returned.
Definition: switch_odbc.c:547
switch_odbc_status_t switch_odbc_handle_disconnect(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:126
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42