--批量操作

    --1 db:execSQLBatch() 批量插入,报错则自动回滚
    local sqlHelp = CSQLBatchStringHelp();
    for i = 0 , 10  do
        local  sql=[[insert into bs_eqpt(eqpt_id,eqpt_code,eqpt_name)
                     values('%s','%s','%s')]]
        sql=string.format(sql,i,i..'code',i..'name')
        sqlHelp:inSQL(sql,'');
    end 
    local sError = CTNString()
    if db:execSQLBatch(sqlHelp:toString(),sError) == false then 
        print(db:error());
        return false;
    end

    --2 db:bulkToDB() 调用bcp.exe程序进行入库,
    local sBCPPath=[[C:/Program Files/Microsoft SQL Server/
                     Client SDK/ODBC/110/Tools/Binn\bcp.exe]]
    local sTable='tn_iot_his.dbo.d_da_num_202001' 
    --正常模板放在服务所在目录的bcp_bulk文件夹中 D:\touchnet\tn_iot_server_8842\bcp_bulk
    local sBulkName='d_da_num.fmt'   
    local help=CSelectHelp() --help里存放待入库的数据
    db:bulkToDB(sBCPPath,help,sTable,sBulkName,',','\n');


Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""