FreeSWITCH API Documentation  1.7.0
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 
54 SWITCH_DECLARE(switch_odbc_handle_t *) switch_odbc_handle_new(const char *dsn, const char *username, const char *password);
61  char **err);
62 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);
67 
68 /*!
69  \brief Execute the sql query and issue a callback for each row returned
70  \param file the file from which this function is called
71  \param func the function from which this function is called
72  \param line the line from which this function is called
73  \param handle the ODBC handle
74  \param sql the sql string to execute
75  \param callback the callback function to execute
76  \param pdata the state data passed on each callback invocation
77  \return SWITCH_STATUS_SUCCESS if the operation was successful
78  \note none
79 */
80 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,
81  const char *sql, switch_core_db_callback_func_t callback, void *pdata,
82  char **err);
83 /*!
84  \brief Execute the sql query and issue a callback for each row returned
85  \param handle the ODBC handle
86  \param sql the sql string to execute
87  \param callback the callback function to execute
88  \param pdata the state data passed on each callback invocation
89  \return SWITCH_STATUS_SUCCESS if the operation was successful
90  \note none
91 */
92 #define switch_odbc_handle_callback_exec(handle, sql, callback, pdata, err) \
93  switch_odbc_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \
94  handle, sql, callback, pdata, err)
95 
96 
98 
100 
102 #endif
103 /* For Emacs:
104  * Local Variables:
105  * mode:c
106  * indent-tabs-mode:t
107  * tab-width:4
108  * c-basic-offset:4
109  * End:
110  * For VIM:
111  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
112  */
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:405
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:729
switch_bool_t
Definition: switch_types.h:405
void switch_odbc_handle_destroy(switch_odbc_handle_t **handlep)
Definition: switch_odbc.c:671
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:449
int(* switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames)
switch_odbc_status_t switch_odbc_statement_handle_free(switch_odbc_statement_handle_t *stmt)
Definition: switch_odbc.c:321
switch_odbc_state_t switch_odbc_handle_get_state(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:700
switch_bool_t switch_odbc_available(void)
Definition: switch_odbc.c:738
void switch_odbc_set_num_retries(switch_odbc_handle_t *handle, int num_retries)
Definition: switch_odbc.c:110
switch_odbc_status_t switch_odbc_handle_connect(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:336
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:760
char * switch_odbc_handle_get_error(switch_odbc_handle_t *handle, switch_odbc_statement_handle_t stmt)
Definition: switch_odbc.c:709
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:65
switch_odbc_status_t switch_odbc_SQLSetAutoCommitAttr(switch_odbc_handle_t *handle, switch_bool_t on)
Definition: switch_odbc.c:747
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:540
switch_odbc_status_t switch_odbc_handle_disconnect(switch_odbc_handle_t *handle)
Definition: switch_odbc.c:119
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42