--数据库事务

    --db:begin() 事务开始, db:commit() 事务提交 db:rollback() 事务回滚

    db:begin() --事务开始
    local sqlInsert=[[insert into bs_eqpt(eqpt_id,eqpt_code,eqpt_name)
                        values('123123','测试设备编号','测试设备名称')]]
    if db:execSQL(sqlInsert,'') ==false  then  
        db:rollback() --回滚
        print(db:error());
        return false;
    end 

    local sqlUpdate=[[update bs_customer set customer_id='1' where customer_id='2' ]]
    if db:execSQL(sqlUpdate,'') ==false  then  
        db:rollback() --回滚
        print(db:error());
        return false;
    end 
    db:commit() --事务提交


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

results matching ""

    No results matching ""