我有一个需要定期更新的数据库。我的雇主希望在MS Access中保留它的基本实例,并在本地SQLite表中更新一个。
我已经能够从MS Access表中获取所有数据(到XML中),但是当我尝试将其插入到SQLite表中时,我得到的错误是复合词中有太多术语选择陈述。
我知道SQLite限制复合选择插入到500,但是这个数据库超过150,000行。我对如何移动数据感到茫然。
有人有任何想法吗?
以下是我尝试使用的代码:
var sqlItem:String="INSERT INTO items (itemID,barcode,desc,brandNum,size,units,multQty,multPrice,price,brand,cat01,catSub,cost,srp,lastPriceChangeDate,lastScanDate,addDate,chgDate) ";
for each(var i:XML in itemList.item){
sqlItem=sqlItem+"SELECT "+
parseInt(i.itemID,10)+","+
parseInt(i.barcode,10)+","+
"\""+i.description+"\","+
parseInt(i.brandNum,10)+","+
"\""+i.size+"\","+
"\""+i.units+"\","+
parseInt(i.multQty,10)+","+
"\""+i.multPrice+"\","+
"\""+i.price+"\","+
"\""+i.brand+"\","+
"\""+i.cat01+"\","+
"\""+i.catSub+"\","+
"\""+i.cost+"\","+
"\""+i.srp+"\","+
"\""+i.lastPriceChangeDate+"\","+
"\""+i.lastScanDate+"\","+
"\""+i.addDate+"\","+
"\""+i.chgDate+"\""+
" UNION ";
}
sqlItem=sqlItem.substring(0,sqlItem.length-7);
itemStmt.text=sqlItem;
try{
itemStmt.execute();
}catch(error:SQLError){
trace("Update USER Database - ERROR: "+error.detailID +" - "+error.details );
}
以下是我正在读入数据库的XML示例:
<items>
<item>
<itemID>1234</itemID>
<barcode>01111111111111</barcode>
<description>Product Description</description>
<brandNum>1</brandNum>
<size>1</size>
<units>oz.</units>
<multQty>1</multQty>
<multPrice>0.85</multPrice>
<price>0.85</price>
<brand>Product Brand</brand>
<cat01>Product Category</cat01>
<catSub>(none)</catSub>
<cost>0.10</cost>
<srp>0.95</srp>
<lastPriceChangeDate>1/9/2009 3:32:29 PM</lastPriceChangeDate>
<lastScanDate>1/9/2009 3:32:29 PM<lastScanDate>
<addDate/>1/9/2009 3:32:29 PM<addDate/>
<chgDate>1/9/2009 3:32:29 PM</chgDate>
</item>
<item>
<itemID>1234</itemID>
<barcode>01111111111111</barcode>
<description>Product Description</description>
<brandNum>1</brandNum>
<size>1</size>
<units>oz.</units>
<multQty>1</multQty>
<multPrice>0.85</multPrice>
<price>0.85</price>
<brand>Product Brand</brand>
<cat01>Product Category</cat01>
<catSub>(none)</catSub>
<cost>0.10</cost>
<srp>0.95</srp>
<lastPriceChangeDate>1/9/2009 3:32:29 PM</lastPriceChangeDate>
<lastScanDate>1/9/2009 3:32:29 PM<lastScanDate>
<addDate/>1/9/2009 3:32:29 PM<addDate/>
<chgDate>1/9/2009 3:32:29 PM</chgDate>
</item>
</items>
答案 0 :(得分:0)
试试这个解决方案吧!!!我甚至在基于sqlite的Web Sql DB中测试了这个解决方案
选择sqlite_version()
INSERT INTO items (val)
select * from
(select 1 val union all
select 2 val union all
select 3 val union all
select 4 val union all
...
select 500 val
)
union all
select * from
(select 501 val union all
select 502 val union all
select 503 val union all
select 504 val union all
...
select 1000 val
)
union all
select * from
(select 1001 val union all
select 1002 val union all
select 1003 val union all
select 1004 val union all
...
select 1500 val
)
...