diff --git a/src/switch_odbc.c b/src/switch_odbc.c index 48ba62c..c226470 100644 --- a/src/switch_odbc.c +++ b/src/switch_odbc.c @@ -47,6 +47,12 @@ #define SQL_NO_DATA SQL_SUCCESS #endif +typedef enum database_type_e { + ODBC_DATABASE_GENERIC, + ODBC_DATABASE_FIREBIRD, + ODBC_DATABASE_ORACLE +}; + struct switch_odbc_handle { char *dsn; char *username; @@ -55,7 +61,7 @@ struct switch_odbc_handle { SQLHDBC con; switch_odbc_state_t state; char odbc_driver[256]; - BOOL is_firebird; + database_type_e database_type; int affected_rows; }; #endif @@ -156,8 +162,10 @@ static int db_is_up(switch_odbc_handle_t *handle) goto done; } - if (handle->is_firebird) { + if (handle->database_type & ODBC_DATABASE_FIREBIRD) { strcpy((char *) sql, "select first 1 * from RDB$RELATIONS"); + } else if (handle->database_type & ODBC_DATABASE_ORACLE) { + strcpy((char *) sql, "select first 1 * from DUAL"); } else { strcpy((char *) sql, "select 1"); } @@ -336,9 +344,11 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_hand } if (strstr(handle->odbc_driver, "FIREBIRD") != 0 || strstr(handle->odbc_driver, "FB32") != 0 || strstr(handle->odbc_driver, "FB64") != 0) { - handle->is_firebird = TRUE; + handle->database_type = ODBC_DATABASE_FIREBIRD; + } else if (strstr(handle->odbc_driver, "ORACLE") != 0) { + handle->database_type = ODBC_DATABASE_ORACLE; } else { - handle->is_firebird = FALSE; + handle->database_type = ODBC_DATABASE_GENERIC; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connected to [%s]\n", handle->dsn);