作者honyihon (lantis)
看板Database
标题[SQL ] c++ 批量输入MySQL
时间Thu Oct 2 18:34:14 2014
资料库名称:MySQL
资料库版本:Ubuntu 系统
内容/问题描述:批量insert 使用c++ 实作帮我看看哪里有问题
code (主要是str里面的东西送到令一个函式输入)我每100笔丢过去
-------------------------
int count=0;
string str;
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 (count <= 100)
{
// concatinate the string with prev str
str += ' (i,j,combine[i],combine[j])'+',';
}
if (count ==100 || count == 0)
{
// execute the string
mysqlinsert(str);
// initialize str as empty string
str = 'INSERT INTO EM (
sourceindex,targetindex,source,target) VALUES';
count = 0;
}
}
}
--------------------------------------------------------
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 163.22.21.92
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Database/M.1412246058.A.C76.html
1F:推 GoalBased: 错误讯息贴出来啊 10/02 18:35
2F:推 GoalBased: 还有..不知道是我太久没写C了吗 字串相加应该是用 "" ? 10/02 18:36
3F:→ tedcat: insert後面的value如果是字串都要用单引号包住吧? 10/03 09:20
4F:→ honyihon: str +=(i,j,combine[i],combine[j])+','; 改成这样 10/03 15:29
5F:→ honyihon: 先cout 出来括弧都消失了 10/03 15:30