Home » U++ Library support » U++ SQL » SqlMassinsert
|
Re: SqlMassinsert [message #34269 is a reply to message #34193] |
Mon, 07 November 2011 14:14 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Here is the code snippet that uses MassInsert to copy Dbf database into SQL database:
DbfStream dbf;
if(!dbf.Open(file))
return false;
SqlMassInsert ins(table);
while(dbf.Fetch())
if(!IsNull(dbf[c[0]])) {
for(int i = 0; i < c.GetCount(); i++)
ins(SqlId(c[i]), dbf[c[i]]);
ins.EndRow();
if(SQL.WasError()) {
ProgressEnd();
return false;
}
}
}
ins.Flush();
SqlMassInsert uses "insert into ... select ... union all ... select" trick to combine many inserts into single SQL statement; this speeds up things as there can be only single locking / index redoing for the whole statement... (Note that it has special complex logic for NULL values that otherwise pose a problem in this strategy).
Mirek
[Updated on: Mon, 07 November 2011 14:15] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 19 21:52:33 CEST 2024
Total time taken to generate the page: 0.03627 seconds
|