diff --git a/Platform/user/database/database.c b/Platform/user/database/database.c index 3e9bc8e58..288e611ae 100644 --- a/Platform/user/database/database.c +++ b/Platform/user/database/database.c @@ -91,10 +91,9 @@ void * connect_database (int module_id) SQLAllocHandle( SQL_HANDLE_DBC, henv, &hdbc ); SQLSetConnectAttr( hdbc, SQL_ATTR_ODBC_CURSORS, (SQLPOINTER)SQL_CUR_USE_ODBC, 0 ); + ret = SQLConnect( hdbc, "meng", SQL_NTS, "", SQL_NTS, "", SQL_NTS ); - - DumpODBCLog(NULL, hdbc, NULL); - if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) + if (ret != SQL_SUCCESS) { return NULL; } @@ -121,12 +120,14 @@ void * connect_database (int module_id) int disconnect_database (int module_id, void * db_handle) { SQLRETURN ret; + if (NULL == db_handle) { return DB_RET_PARAM_NULL; } SQLDisconnect(db_handle); + ret = SQLFreeHandle(SQL_HANDLE_DBC, db_handle); if (ret != SQL_SUCCESS) { @@ -213,7 +214,6 @@ int update_database(int module_id, void * db_handle, int op_type, char * tabl return DB_RET_PARAM_NULL; } - if ((op_type != DB_OP_INSERT) && (op_type != DB_OP_DEL) && (op_type != DB_OP_UPDATE)) { return DB_RET_PARAM_ERR; @@ -272,7 +272,8 @@ int update_database(int module_id, void * db_handle, int op_type, char * tabl } else { - printf("\n type error : %d", type); + /* 当前只支持以上三种类型,如果不是则打印报错 */ + printf("\n type error : %d", type); } } @@ -285,8 +286,7 @@ int update_database(int module_id, void * db_handle, int op_type, char * tabl SQLFreeStmt(hstmt, SQL_DROP); if (ret != SQL_SUCCESS) - { - DumpODBCLog(NULL, db_handle, hstmt); + { return DB_RET_ERR; } @@ -346,7 +346,7 @@ void * select_datebase_by_number(int module_id, void * db_handle, char * table_ return NULL; } - ret = SQLAllocHandle( SQL_HANDLE_STMT, db_handle, &hstmt); + ret = SQLAllocHandle(SQL_HANDLE_STMT, db_handle, &hstmt); if ((SQL_INVALID_HANDLE == ret) || (SQL_ERROR == ret)) { return NULL; @@ -429,7 +429,8 @@ void * select_datebase_by_number(int module_id, void * db_handle, char * table_ } else { - + /* 当前只支持以上三种类型,如果不是则打印报错 */ + printf("\n type error : %d", type); } } @@ -464,7 +465,7 @@ void * select_datebase_by_number(int module_id, void * db_handle, char * table_ } else { - + /* 不支持的类型 */ } } @@ -488,9 +489,6 @@ void * select_datebase_by_number(int module_id, void * db_handle, char * table_ for (j = 1; j <= column_nmuber; j++) { - printf("\n db_column_info[j].dateType: %d j : %d", db_column_info[j].dateType, j); - - if (SQL_BIGINT == db_column_info[j].dateType) { cJSON_AddNumberToObject(obj, db_column_info[j].name, *((long long *)&(value[j][0]))); @@ -545,13 +543,13 @@ void * select_datebase_by_number(int module_id, void * db_handle, char * table_ int free_database_memory(int module_id, char * table_name, void * memory_ptr) { if ((NULL == table_name) && (NULL == memory_ptr)) - { + { return DB_RET_PARAM_NULL; - } + } - free(memory_ptr); + free(memory_ptr); - return DB_RET_OK; + return DB_RET_OK; } /*********************************************************************************   * Description:   @@ -656,6 +654,8 @@ int get_select_datebase_number(int module_id, void * db_handle, char * table_n } } + va_end(ap); + ret = SQLExecute(hstmt); }