Home > Back-end >  Using otl_stream bulk insert data, but can only be inserted into the first
Using otl_stream bulk insert data, but can only be inserted into the first

Time:09-26

Code is roughly as follows:
 
# define OTL_ODBC
Int main (int arg c, char * argv []) {
Otl_connect dbconn (user/pw);
Otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
For (int index=1; The index & lt;=100; + + index) {
Otls & lt; & lt; The index & lt; & lt; The index;
}
return 0;
}

Theory when the buffer to fill, will automatically refresh and commit the transaction, namely insert 100 data,
Actually committing only by inserting a, namely the values into the (1, 1), (11, 11), (21, 21)...
The database version: 5.0.27, ODBC version: 5.1, engine: innodb
To solve the,

CodePudding user response:

# define OTL_ODBC
Int main (int arg c, char * argv []) {
Otl_connect dbconn (user/pw);
Otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
For (int index=1; The index & lt;=100; + + index) {
Otls & lt; & lt; The index & lt; & lt; The index;
}
return 0;
}

The otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
In the 10 to 1, give it a try?

CodePudding user response:

reference 1st floor McHdba response:
# define OTL_ODBC
Int main (int arg c, char * argv []) {
Otl_connect dbconn (user/pw);
Otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
For (int index=1; The index & lt;=100; + + index) {
Otls & lt; & lt; The index & lt; & lt; The index;
}
return 0;
}

The otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
In the 10 to 1, give it a try?

1 of course, no problem, but not equivalent to use buffer, every article submission,
I see a lot of posts are made of similar code, I don't know why I not successful...

CodePudding user response:

refer to the second floor mindfuck response:
Quote: refer to 1st floor McHdba response:

# define OTL_ODBC
Int main (int arg c, char * argv []) {
Otl_connect dbconn (user/pw);
Otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
For (int index=1; The index & lt;=100; + + index) {
Otls & lt; & lt; The index & lt; & lt; The index;
}
return 0;
}

The otl_stream otls (10, "INSERT INTO the table VALUES (: id To: value) ", dbconn);
In the 10 to 1, give it a try?

1 of course, no problem, but not equivalent to use buffer, every article submission,
I see a lot of posts are made of similar code, I don't know why I not successful...

I think you here below 10 not submit number, but perform interval number?

CodePudding user response:

Could you tell me how to solve the original poster is?
  • Related