zoukankan      html  css  js  c++  java
  • 在QueryRange里面慎用strfmt拼出来的条件

        gStartAmount = -40000;
        gEndAmount = -1;
    使用下面的语句
        gStrAmountRangeCredit =  strfmt("%1..%2",gStartAmount,gEndAmount);
        gStrAmountRangeDebit =  strfmt("%1..%2",-1*gEndAmount,-1*gStartAmount);

        Qbds.addRange(fieldnum(LedgerTrans,AmountCur)).value(gStrAmountRangeCredit);
    拼出来的SQL居然是下面的:
    NAME:
     Qbds
    VALUE:
     SELECT * FROM LedgerTrans WHERE ((TransDate>={ts '2009-07-01 00:00:00.000'} AND TransDate<={ts '2009-07-31 00:00:00.000'})) AND ((AmountCur = -4.E1 OR AmountCur>=1.E0 AND AmountCur<=-1.E0)) AND ((Crediting = 0)) JOIN * FROM LedgerJournalTable WHERE LedgerTrans.JournalNum = LedgerJournalTable.JournalNum
    TYPE:
     QueryBuildDataSource
    无语!!

    调整为下面的写法:
        gStrAmountRangeCredit =  num2str(gStartAmount,10,2,1,0) + ".."+ num2str(gEndAmount,10,2,1,0);//strfmt("%1..%2",gStartAmount,gEndAmount);
        gStrAmountRangeDebit =  num2str(-1*gEndAmount,10,2,1,0) + ".."+ num2str(-1*gStartAmount,10,2,1,0);//strfmt("%1..%2",-1*gEndAmount,-1*gStartAmount);

    Qbds.addRange(fieldnum(LedgerTrans,AmountCur)).value(gStrAmountRangeCredit);
    拼出来的语句是正确的:
    NAME:
     Qbds
    VALUE:
     SELECT * FROM LedgerTrans WHERE ((TransDate>={ts '2009-07-01 00:00:00.000'} AND TransDate<={ts '2009-07-31 00:00:00.000'})) AND ((AmountCur>=-4.00001E5 AND AmountCur<=-1.E0)) AND ((Crediting = 0)) JOIN * FROM LedgerJournalTable WHERE LedgerTrans.JournalNum = LedgerJournalTable.JournalNum
    TYPE:
     QueryBuildDataSource
  • 相关阅读:
    静态成员在类中的初始化
    博客中尖括号不显示的问题
    声明vector对象保存函数指针
    返回数组指针的函数
    C++ 指针与引用的差别
    Configure Eclipse “Content Assist”
    How to install Eclipse-Color-Theme
    国内 git 托管平台
    SHA1 对文件求信息摘要的实现
    SHA1 对字符串求摘要的实现
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/1533286.html
Copyright © 2011-2022 走看看