--- cdr/cdr_adaptive_odbc.c.orig 2010-12-14 14:45:23.000000000 +0000 +++ cdr/cdr_adaptive_odbc.c 2010-12-14 15:16:35.000000000 +0000 @@ -88,7 +88,8 @@ char columnname[80]; char connection[40]; char table[40]; - int lenconnection, lentable, usegmtime = 0; + char schema[40]; + int lenconnection, lentable, lenschema, usegmtime = 0; SQLLEN sqlptr; int res = 0; SQLHSTMT stmt = NULL; @@ -130,6 +131,12 @@ ast_copy_string(table, tmp, sizeof(table)); lentable = strlen(table); + if(ast_strlen_zero(tmp = ast_variable_retrieve(cfg, catg, "schema"))) { + tmp = ""; + } + ast_copy_string(schema, tmp, sizeof(schema)); + lenschema = strlen(schema); + res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { ast_log(LOG_WARNING, "SQL Alloc Handle failed on connection '%s'!\n", connection); @@ -137,7 +144,7 @@ continue; } - res = SQLColumns(stmt, NULL, 0, NULL, 0, (unsigned char *)table, SQL_NTS, (unsigned char *)"%", SQL_NTS); + res = SQLColumns(stmt, NULL, 0, lenschema == 0 ? NULL : (unsigned char *)schema, SQL_NTS, (unsigned char *)table, SQL_NTS, (unsigned char *)"%", SQL_NTS); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { ast_log(LOG_ERROR, "Unable to query database columns on connection '%s'. Skipping.\n", connection); ast_odbc_release_obj(obj);