ASQLite3UpdateSQL 解析UpdateSQL中的BUG

ASQLite3控件在SQLite数据库开发中比较好用,在ASQLite3Query 连接 ASQLite3UpdateSQL 更新数据库

 

ASQLite3UpdateSQL中
(f_id为主键,tj为表名)
 DeleteSQL : delete tj  where f_id=:f_id 
 InsertSQL : INSERT INTO tj *
 UpdateSQL : UPDATE tj * WHERE f_id=:f_id

 

其中使用UpdateSQL老报错,根据跟踪调试,发现问题:

 

ASGSQLite3.pas 有BUG:

 

在procedure TASQLite3Query.InternalPost 中:

 

第4628,4629行原来这样:
 4628:     TheWord := GetWord(MySQL, startpos, vartype); // , or 'where'
 4629:       until AnsiCompareText(TheWord, 'where') = 0;
 4630:     end;
 4631:       if not SyntaxCheck(TheWord, 'where') then
 4632:          raise AsgError.Create('Syntax error: "where" expected')
 4633:       else
 4634:          SQLStr := SQLStr + ' where ';
 4635:       SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
 4636:       Connection.SQLite3_ExecSQL(SQLStr, Fields);
 4637:       inherited InternalPost;           // rework internals


改成:

 4628:     TheWord := GetWord(MySQL, startpos, vartype); // , or 'where'
 4629:     if TheWord =',' then  SQLStr := SQLStr +',' ;    // (增加这行)
 4630:       until AnsiCompareText(TheWord, 'where') = 0;
 4631:       if not SyntaxCheck(TheWord, 'where') then
 4632:          raise AsgError.Create('Syntax error: "where" expected')
 4633:       else
 4634:          SQLStr := SQLStr + ' where ';
 4635:       SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
 4636:    end;  // 原4630行的end 移动到这里
 4637:       Connection.SQLite3_ExecSQL(SQLStr, Fields);
 4638:       inherited InternalPost;           // rework internals

增加4629行是为了解决update tj set fphm=:fphm,rq=:rq where f_id=:f_id 这样写时生成的UpdateSQL中间没有','的错。
移动4630的'end;'是为了解决update tj * where f_id=:f_id 这样写时生成的UpdateSQL中重复生成'where'内容!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值