gpt4 book ai didi

c++ - for 循环批处理数据并将其丢弃在 C++ 中

转载 作者:行者123 更新时间:2023-11-28 06:40:04 24 4
gpt4 key购买 nike

void write_token_to_data()
{
typedef double* DynamicMatrix[l+m];
// DynamicMatrix Count;
typedef double* DynamicMatrix2[l+m];
//DynamicMatrix2 Prob;
for(int i=0; i<(l+m); i++)
{
for(int j=0; j<(l+m); j++)
{
if(mysqlinsert2(i,j,combine[i],combine[j]))
{
cout<<"insert OK!!"<<endl;
}
else
{
cout<<"insert failed"<<endl;
}


}
}

}//end of function

这是我的问题我怎样才能改变这个子功能,我可以保持 i , j combine[i], combine[j]直到数字100,将这四个值丢入mysqlinsert函数并释放 for 循环索引 101 中的数组并继续记录值,长话短说,我想将这个 mysql 插入分成一小部分

最佳答案

 - You can contruct a string in the form
(i,j,cobine[i],combine[j]) for each iteration.
- Inorder to insert a multiple rows in a single query.
[Normal insert query for multiple records
INSERT INTO Table ( Column1, Column2 ) VALUES
( Value1, Value2 ), ( Value1, Value2 )
]
- also rewrite mysqlinsert2(i,j,combine[i],combine[j]) into *mysqlinsert2(str)*.and execute the string.

for(int i=0; i<(l+m); i++){
for(int j=0; j<(l+m); j++){
if (till count => 100) {
// concatinate the string with prev str
str += (i,j,combine[i],combine[j])+',';
}
if (count reaches hundred || count = 0) {
// execute the string
mysqlinsert2(str);
// initialize str as empty string
str = 'INSERT INTO Table ( Column1, Column2, column3, column4 ) VALUES';
count = 0;
}
}
}

关于c++ - for 循环批处理数据并将其丢弃在 C++ 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26136212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com