| 22 |
* |
* |
| 23 |
* $Revision$ |
* $Revision$ |
| 24 |
* $Log$ |
* $Log$ |
| 25 |
|
* Revision 1.91 2005/06/07 01:10:33 tani |
| 26 |
|
* SQLGetDataの引数を修正. |
| 27 |
|
* SQLExecDirectの代わりにSQLExecuteの利用. |
| 28 |
|
* |
| 29 |
* Revision 1.90 2005/05/23 08:00:30 tani |
* Revision 1.90 2005/05/23 08:00:30 tani |
| 30 |
* insertGroup, updateGroup: グループ名が重複した場合はエラーコードを返す. |
* insertGroup, updateGroup: グループ名が重複した場合はエラーコードを返す. |
| 31 |
* |
* |
| 764 |
SQLLEN cbModule = SQL_NTS, cbKey = SQL_NTS; |
SQLLEN cbModule = SQL_NTS, cbKey = SQL_NTS; |
| 765 |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule ); |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(module), 0, (SQLCHAR *)module, 0, &cbModule ); |
| 766 |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key), 0, (SQLCHAR *)key, 0, &cbKey ); |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(key), 0, (SQLCHAR *)key, 0, &cbKey ); |
| 767 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){ |
sqlcode = SQLExecute( hstmt ); |
| 768 |
|
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 769 |
if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){ |
if ( ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS ){ |
| 770 |
string s = getResultCol( hstmt, 1 ); |
string s = getResultCol( hstmt, 1 ); |
| 771 |
*value = new char[s.length()+1]; |
*value = new char[s.length()+1]; |
| 3252 |
SQLLEN cbUname = SQL_NTS, cbPasswd = SQL_NTS; |
SQLLEN cbUname = SQL_NTS, cbPasswd = SQL_NTS; |
| 3253 |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname ); |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(uname), 0, (SQLCHAR *)uname, 0, &cbUname ); |
| 3254 |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd ); |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, strlen(passwd),0, (SQLCHAR *)passwd,0, &cbPasswd ); |
| 3255 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), strlen( sql.c_str() ) ) ) == SQL_SUCCESS ){ |
sqlcode = SQLExecute( hstmt ); |
| 3256 |
|
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 3257 |
SQLUINTEGER sUID = 0; |
SQLUINTEGER sUID = 0; |
| 3258 |
SQLLEN len = 0; |
SQLLEN len = 0; |
| 3259 |
SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len ); |
SQLBindCol( hstmt, 1, SQL_C_ULONG, &sUID, 0, &len ); |
| 6261 |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6262 |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue ); |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue ); |
| 6263 |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
| 6264 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
sqlcode = SQLExecute( hstmt ); |
| 6265 |
|
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6266 |
SQLLEN count = 0; |
SQLLEN count = 0; |
| 6267 |
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
if( ( sqlcode = SQLRowCount( hstmt, &count ) ) == SQL_SUCCESS && count > 0 ){ |
| 6268 |
ret = RES_OK; |
ret = RES_OK; |
| 6273 |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6274 |
SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
SQLBindParameter(hstmt2, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key , strlen(key) , &cbKey ); |
| 6275 |
SQLBindParameter(hstmt2, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue ); |
SQLBindParameter(hstmt2, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, SQL_DESC_LENGTH, 0, (SQLCHAR*)value, strlen(value), &cbValue ); |
| 6276 |
if( ( sqlcode = SQLExecDirect( hstmt2, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
sqlcode = SQLExecute( hstmt ); |
| 6277 |
|
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6278 |
if( ( sqlcode = SQLRowCount( hstmt2, &count ) ) == SQL_SUCCESS && count > 0 ){ |
if( ( sqlcode = SQLRowCount( hstmt2, &count ) ) == SQL_SUCCESS && count > 0 ){ |
| 6279 |
ret = RES_OK; |
ret = RES_OK; |
| 6280 |
} |
} |
| 6293 |
SQLFreeHandle( SQL_HANDLE_STMT, hstmt2 ); |
SQLFreeHandle( SQL_HANDLE_STMT, hstmt2 ); |
| 6294 |
}else{ |
}else{ |
| 6295 |
string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in setConfigValue" ); |
string s( "SQLAllocHandle(SQL_HANDLE_STMT,...) in setConfigValue" ); |
| 6296 |
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
s += odbcDiagString( SQL_HANDLE_DBC, hdbc, sqlcode ); |
| 6297 |
setLastErrorString( s.c_str( ) ); |
setLastErrorString( s.c_str( ) ); |
| 6298 |
ret = RES_ERROR; |
ret = RES_ERROR; |
| 6299 |
} |
} |
| 6300 |
}else{ |
}else{ |
| 6341 |
string sql("SELECT value FROM " + dbprefix + "_xoonips_config WHERE name=?"); |
string sql("SELECT value FROM " + dbprefix + "_xoonips_config WHERE name=?"); |
| 6342 |
sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS); |
sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS); |
| 6343 |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6344 |
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key, strlen(key), &cbKey ); |
sqlcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_CONFIG_NAME_LEN, 0, (SQLCHAR*)key, 0, &cbKey ); |
| 6345 |
if( ( sqlcode = SQLExecDirect( hstmt, (SQLCHAR*)sql.c_str(), sql.length() ) ) == SQL_SUCCESS ){ |
syslog_printf( "SQLBindParameter %d", sqlcode); |
| 6346 |
|
if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){ |
| 6347 |
while( SQLFetch( hstmt ) == SQL_SUCCESS ){ |
while( SQLFetch( hstmt ) == SQL_SUCCESS ){ |
| 6348 |
SQLLEN length = 0; |
SQLLEN length = 0; |
| 6349 |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
syslog_printf( "\nsql at %d=%s", __LINE__, sql.c_str() ); |
| 6350 |
if( dbtype == DBTYPE_MYSQL ){ |
if( dbtype == DBTYPE_MYSQL ){ |
| 6351 |
// get amount of data |
// get amount of data |
| 6352 |
if( SQLGetData(hstmt, 1, SQL_C_BINARY, *value, 0, &length) |
sqlcode = SQLGetData(hstmt, 1, SQL_C_BINARY, value, 0, &length); |
| 6353 |
== SQL_SUCCESS_WITH_INFO ){ |
syslog_printf( "sqlreturn : %d length %d", sqlcode, length); |
| 6354 |
|
if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){ |
| 6355 |
// Get all the data at once. |
// Get all the data at once. |
| 6356 |
*value = new char[ length + 1 ]; |
*value = new char[ length + 1 ]; |
| 6357 |
memset( *value, '\0', length + 1 ); |
memset( *value, '\0', length + 1 ); |