当前位置: 首页>>代码示例>>C++>>正文


C++ Statement::executeUpdate方法代码示例

本文整理汇总了C++中Statement::executeUpdate方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::executeUpdate方法的具体用法?C++ Statement::executeUpdate怎么用?C++ Statement::executeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::executeUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NotifyOrder

int ChargeBusiness::NotifyOrder(TopupInfo *topupInfo){
    int ret = 0;
    Statement *stmt = NULL;
    try{
        string ts;
        get_time_now("%Y/%m/%d %H:%M:%S", ts);
        int notify = 1;
        stmt = conn->createStatement(SQL_UPDATE_NOTIFY);
        stmt->setAutoCommit(false);
        string sysNo = topupInfo->qs_info.coopOrderNo;
        stmt->setInt(1, topupInfo->notify);
        stmt->setString(2, ts);
        stmt->setString(3, sysNo);
        stmt->executeUpdate();
    }catch(SQLException &sqlExcp){
        HandleException(sqlExcp);
        ret = -1;
    }catch(std::exception &e){
        HandleException(e);
    }
    if(stmt)
        conn->terminateStatement(stmt);
    Finish();
    return ret;
}
开发者ID:desion,项目名称:topup_service,代码行数:25,代码来源:ChargeBusiness.cpp

示例2: VerifyWeixin

//验证用户微信号
int ChargeBusiness::VerifyWeixin(string userId, string openId){
    Statement *stmt = NULL;
    int ret = 0;
    try{
        stmt = conn->createStatement(QUERY_USER_SQL);
        stmt->setString(1, userId);
        ResultSet *rs = stmt->executeQuery();
        string user_open_id;
        int id = -1;
        while(rs->next())
        {
            id = rs->getInt(1);
            user_open_id = rs->getString(2);
        }
        if(id == -1){
            ret = 1;
        }else if(user_open_id.empty()){
            conn->terminateStatement(stmt);
            stmt = conn->createStatement(VERIFY_SQL);
            stmt->setString(1, openId);
            stmt->setString(2, userId);
            stmt->executeUpdate();
        }else{
            ret = 2;
        }
        
    }catch(SQLException &sqlExcp){
        HandleException(sqlExcp);
    }catch(std::exception &e){
        HandleException(e);
    }   
    if(stmt)
        conn->terminateStatement(stmt);
    return ret;
}
开发者ID:desion,项目名称:topup_service,代码行数:36,代码来源:ChargeBusiness.cpp

示例3: UpdateChannel

int ChargeBusiness::UpdateChannel(TopupInfo *topupInfo){
    int ret = 0;
    Statement *stmt = NULL;
    try{
        stmt = conn->createStatement(SQL_UPDATE_CHANNEL);
        stmt->setAutoCommit(false);
        string tbOrderNo = topupInfo->qs_info.coopOrderNo;
        stmt->setInt(1, topupInfo->channelId);
        int total_value = topupInfo->qs_info.value * topupInfo->qs_info.cardNum;
        stmt->setFloat(2, total_value * topupInfo->channel_discount);
        stmt->setFloat(3, topupInfo->qs_info.sum - total_value * topupInfo->channel_discount);
        stmt->setString(4, tbOrderNo);
        stmt->executeUpdate();
    }catch(SQLException &sqlExcp){
        HandleException(sqlExcp);
        ret = -1;
    }catch(std::exception &e){
        HandleException(e);
        ret = -1;
    }
    Finish();
    if(stmt)
        conn->terminateStatement(stmt);
    return ret;
}
开发者ID:desion,项目名称:topup_service,代码行数:25,代码来源:ChargeBusiness.cpp

示例4: db_createPlayerInfo

	int db_createPlayerInfo(Connection *conn, const PlayerInfo *info)
	{
		boost::format fmter("insert into g_user(user_name,user_pwd,level,gender,role_id,scene_id,x,y) values('%s','%s',%d,%d,%d,%d,%d,%d)");
		fmter % info->user_name;
		fmter % info->user_pwd;
		fmter % info->level;
		fmter % (int)info->gender;
		fmter % info->role_id;
		fmter % info->scene_id;
		fmter % info->x;
		fmter % info->y;
		
		std::string sql = boost::str(fmter);
		int ret = 0;
		
		Statement *stmt = conn->createStatement();
		try
		{
			ret = stmt->executeUpdate(sql.c_str());
		}
		catch (sql::SQLException &e)
		{
			sLog.outError("[db_createPlayerInfo] sql error :%s errorCode: %d", e.what(), e.getErrorCode());
		}
	
		delete stmt;
		return ret;
	}
开发者ID:hcqmaker,项目名称:simple_game,代码行数:28,代码来源:PlayerModule.cpp

示例5: callfun

    // Function to call a PL/SQL function
    void callfun ()
    {   cout << "callfun - invoking a PL/SQL function having IN, OUT and IN/OUT ";
        cout << "parameters" << endl;
        Statement *stmt = con->createStatement
                          ("BEGIN :a := demo_fun(:v1, :v2, :v3); END;");
        try {
            cout << "Executing the block :" << stmt->getSQL() << endl;
            stmt->setInt (2, 10);
            stmt->setMaxParamSize (3, 30);
            stmt->setString (3, "IN");
            stmt->registerOutParam (1, OCCISTRING, 30, "");
            stmt->registerOutParam (4, OCCISTRING, 30, "");
            int updateCount = stmt->executeUpdate ();
            cout << "Update Count : " << updateCount << endl;

            string c1 = stmt->getString (1);
            string c2 = stmt->getString (3);
            string c3 = stmt->getString (4);

            cout << "Printing the INOUT & OUT parameters :" << endl;
            cout << "Col2: " << c2 << endl;
            cout << "Col3: " << c3 << endl;
            cout << "Printing the return value of the function: ";
            cout << c1 << endl;

            con->terminateStatement (stmt);
            cout << "occifun - done" << endl;
        }
        catch (SQLException ex) {
            cout << ex.getMessage() << endl;
        }
    } // end of callfun ()
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:33,代码来源:occiproc.cpp

示例6: UpdateOrderStatus

int ChargeBusiness::UpdateOrderStatus(TopupInfo *topupInfo){
    int ret = 0;
    Statement *stmt = NULL;
    try{
        int status = 0;
        if(topupInfo->status == SUCCESS){
            status = 1;
        }else if(topupInfo->status == FAILED){
            status = 2;
        }
        string ts;
        get_time_now("%Y/%m/%d %H:%M:%S", ts);
        int notify = topupInfo->notify;
        stmt = conn->createStatement(SQL_UPDATE_STATUS);
        stmt->setAutoCommit(false);
        string tbOrderNo = topupInfo->qs_info.coopOrderNo;
        stmt->setInt(1, status);
        stmt->setInt(2, notify);
        stmt->setString(3, ts);
        stmt->setString(4, tbOrderNo);
        stmt->executeUpdate();
    }catch(SQLException &sqlExcp){
        HandleException(sqlExcp);
        ret = -1;
    }catch(std::exception &e){
        HandleException(e);
        ret = -1;
    }
    Finish();
    if(stmt)
        conn->terminateStatement(stmt);
    return ret;
}
开发者ID:desion,项目名称:topup_service,代码行数:33,代码来源:ChargeBusiness.cpp

示例7: ExecuteNonQuery

/*
 * @sql_statement SQL语句字符串
 */
bool OraDBOpration::ExecuteNonQuery(string sql_statement)
{
    
    Statement *stmtement = con->createStatement();
    
    try
    {
        stmtement->setSQL(sql_statement);
        stmtement->executeUpdate();
		//con->commit();
    }

    catch (SQLException &ex)
    {
		con->rollback();
        cout << "Exception thrown for NonQuery" << endl;
        cout << "Error number: " << ex.getErrorCode() << endl;
        cout << "Error Msg: "<< ex.getMessage() << endl;
        cout << "SQL: "<<sql_statement << endl;
		con->terminateStatement(stmtement);
		return false;

    }
    con->terminateStatement(stmtement);
	return true;
}
开发者ID:funnybjzs,项目名称:PictureSteganalysisOnline,代码行数:29,代码来源:OraDBOpration.cpp

示例8: warehouse

void Exporter::warehouse()
{
	::Connection *s = NULL;
	Statement *sth = NULL;
	while(1) {
		if((s=_queue->dequeue()) != NULL) {
			if(_conn == NULL) {
				continue;
			}

			try {
			    if(sth == NULL) {
				sth = _conn->createStatement(_query);
				sth->setAutoCommit(true);
			    }
			    //std::cout << *s << std::endl;
			    sth->setInt(1, s->saddr);
			    sth->setInt(2, s->daddr);
			    sth->setInt(3, s->bytes);
			    sth->setInt(4, s->start);
			    sth->setInt(5, s->ts);
			    sth->setString(6, s->conn_data != NULL? s->conn_data->pack() : "");
			    sth->executeUpdate();
			}
			catch(std::exception &e) {
			    std::cerr << "Error executing query: " << e.what() << std::endl;
			    delete(sth);
			    sth = NULL;
			}
			s->setExported(true);
		} else {
			sleep(1);
		}
	}
}
开发者ID:omever,项目名称:CSharker,代码行数:35,代码来源:exporter.cpp

示例9: insertElement

  /**
   * Inserting a row into elements table.
   * Demonstrating the usage of BFloat and BDouble datatypes
   */
  void insertElement (string elm_name, float mvol=0.0, double awt=0.0)
  {
    BFloat mol_vol;
    BDouble at_wt;

    if (!(mvol))
      mol_vol.isNull = TRUE;
    else
      mol_vol.value = mvol;

    if (!(awt))
      at_wt.isNull = TRUE;
    else
      at_wt.value = awt;

    string sqlStmt = "INSERT INTO elements VALUES (:v1, :v2, :v3)";
    stmt = conn->createStatement (sqlStmt);

    try{
    stmt->setString(1, elm_name);
    stmt->setBFloat(2, mol_vol);
    stmt->setBDouble(3, at_wt);
    stmt->executeUpdate ();
    cout << "insertElement - Success" << endl;
    }catch(SQLException ex)
    {
     cout<<"Exception thrown for insertElement"<<endl;
     cout<<"Error number: "<<  ex.getErrorCode() << endl;
     cout<<ex.getMessage() << endl;
    }
    conn->terminateStatement (stmt);
  }
开发者ID:umeshsahoo,项目名称:website_umesh,代码行数:36,代码来源:occidml.cpp

示例10: callproc

 // Function to call a PL/SQL procedure
 void callproc ()
 {
     cout << "callproc - invoking a PL/SQL procedure having IN, OUT and IN/OUT ";
     cout << "parameters" << endl;
     Statement *stmt = con->createStatement
                       ("BEGIN demo_proc(:v1, :v2, :v3); END;");
     try {
         cout << "Executing the block :" << stmt->getSQL() << endl;
         stmt->setInt (1, 10);
         stmt->setMaxParamSize (2, 30);
         stmt->setString (2, "IN");
         stmt->registerOutParam (3, OCCISTRING, 30, "");
         int updateCount = stmt->executeUpdate ();
         cout << "Update Count:" << updateCount << endl;
         string c1 = stmt->getString (2);
         string c2 = stmt->getString (3);
         cout << "Printing the INOUT & OUT parameters:" << endl;
         cout << "Col2: " << c1 << endl;
         cout << "Col3: " << c2 << endl;
         con->terminateStatement (stmt);
         cout << "occiproc - done" << endl;
     }
     catch (SQLException ex) {
         cout << ex.getMessage() << endl;
     }
 } // end of callproc ()
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:27,代码来源:occiproc.cpp

示例11: db_updatePlayerInfo

	int db_updatePlayerInfo(Connection *conn, const PlayerInfo *info)
	{
		std::string sql = "update g_user set ";
		sql.append("user_name='");
		sql.append(info->user_name);
		sql.append("',user_pwd='");
		sql.append(info->user_pwd);
		sql.append("',level=");
		sql.append(info->level + "");
		sql.append(",gender=");
		sql.append(info->gender + "");
		sql.append(",role_id=");
		sql.append(info->role_id + "");
		sql.append(",scene_id=");
		sql.append(info->scene_id + "");
		sql.append(",x=");
		sql.append(info->x + "");
		sql.append(",y=");
		sql.append(info->y + "");
		sql.append(" where user_id=");
		sql.append(info->user_id + "");

		int ret = 0;
		Statement *stmt = conn->createStatement();
		try
		{
			ret = stmt->executeUpdate(sql.c_str());
		}
		catch (sql::SQLException &e)
		{
			sLog.outError("[db_updatePlayerInfo] sql error :%s errorCode: %d", e.what(), e.getErrorCode());
		}
		delete stmt;
		return ret;
	}
开发者ID:hcqmaker,项目名称:simple_game,代码行数:35,代码来源:PlayerModule.cpp

示例12: GenerateNewStat

/**
 * Generate the new statistics and store in the database
 */
void StatController::GenerateNewStat()
{
	Statement* stmt = conn->createStatement();
	//Get the counts of users, sheets, feeds, items and comments and insert into the database
	stmt->executeUpdate("INSERT INTO stats (users, sheets, feeds, items, comments) VALUES ((SELECT count(*) FROM users), (SELECT count(*) FROM sheets), (SELECT count(*) FROM feeds), (SELECT count(*) FROM items), (SELECT count(*) FROM comments))");

	delete stmt;
}
开发者ID:iann0036,项目名称:newsfeeder,代码行数:11,代码来源:StatController.cpp

示例13: Insert

YK_ULLONG YKOracle::Insert(const YKString& sql)
{
	try {
		Statement* stmt = m_connection->createStatement(sql.ToString());
		if (stmt)
		{
			return (YK_ULLONG)stmt->executeUpdate();
		}
	} catch (SQLException& err) {
		YK_ExceptionThrow(YKDSException) << YKDSException::E_Update(GetErrorMessage(err));
	}

	return 0;
}
开发者ID:backo880607,项目名称:YuKonSolution,代码行数:14,代码来源:YKOracle.cpp

示例14: nuodb_execute

int nuodb_execute(struct nuodb *db, const char *sql,
                  int64_t *rows_affected, int64_t *last_insert_id) {
    Statement *stmt = 0;
    try {
        stmt = db->conn->createStatement();
        stmt->executeUpdate(sql, RETURN_GENERATED_KEYS);
        int rc = fetchExecuteResult(db, stmt, rows_affected, last_insert_id);
        stmt->close();
        return rc;
    } catch (SQLException &e) {
        if (stmt) {
            stmt->close();
        }
        return setError(db, e);
    }
}
开发者ID:tilinna,项目名称:go-nuodb,代码行数:16,代码来源:cnuodb.cpp

示例15: insertRow

  /**
   * Inserting a row into the table.
   */
  void insertRow ()
  {
    string sqlStmt = "INSERT INTO author_tab VALUES (111, 'ASHOK')";
    stmt = conn->createStatement (sqlStmt);
    try{
    stmt->executeUpdate ();
    cout << "insert - Success" << endl;
    }catch(SQLException ex)
    {
     cout<<"Exception thrown for insertRow"<<endl;
     cout<<"Error number: "<<  ex.getErrorCode() << endl;
     cout<<ex.getMessage() << endl;
    }

    conn->terminateStatement (stmt);
  }
开发者ID:umeshsahoo,项目名称:website_umesh,代码行数:19,代码来源:occidml.cpp


注:本文中的Statement::executeUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。