[SQL ] c++ 批量輸入MySQL

看板Database (資料庫)作者 (lantis)時間11年前 (2014/10/02 18:34), 編輯推噓2(203)
留言5則, 3人參與, 最新討論串1/1
資料庫名稱: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://www.ptt.cc/bbs/Database/M.1412246058.A.C76.html

10/02 18:35, , 1F
錯誤訊息貼出來啊
10/02 18:35, 1F

10/02 18:36, , 2F
還有..不知道是我太久沒寫C了嗎 字串相加應該是用 "" ?
10/02 18:36, 2F

10/03 09:20, , 3F
insert後面的value如果是字串都要用單引號包住吧?
10/03 09:20, 3F

10/03 15:29, , 4F
str +=(i,j,combine[i],combine[j])+','; 改成這樣
10/03 15:29, 4F

10/03 15:30, , 5F
先cout 出來括弧都消失了
10/03 15:30, 5F
文章代碼(AID): #1KBIegns (Database)
文章代碼(AID): #1KBIegns (Database)