0

我有一个需要定期更新的数据库。我的雇主想在 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>
4

1 回答 1

0

试试这个解决方案吧!!!我什至在基于 sqlite 的 Web Sql DB 中测试了这个解决方案

选择 sqlite_version()

3.6.19

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
)
...
于 2013-01-13T20:31:22.803 回答