lingdanglfw(DAX)

导航

在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

posted on 2009-07-28 19:20  lingdanglfw  阅读(344)  评论(1编辑  收藏  举报