where子句与日期范围给出奇怪的结果

时间:2015-06-22 10:19:20

标签: sql oracle oracle-ebs xml-publisher

在xml发布者报告中,我有以下where子句:

    where  NVL(:P_ORDER_NUMBER, xx.order_number) = xx.order_number  
     and xx.ordered_date between NVL(TRUNC(fnd_date.canonical_to_date(:P_FROM_DATE)), xx.ORDERED_DATE) and NVL(TRUNC(fnd_date.canonical_to_date(:P_TO_DATE)), xx.ORDERED_DATE)  
    AND NVL(:P_CUSTOMER, xx.customer_id) = xx.customer_id

但它的行为很奇怪,日期范围的结果是正常的,但是在日期范围之外,其结果为NULL。

我也尝试了以下内容:

where  NVL(:P_ORDER_NUMBER, xx.order_number) = xx.order_number  
 and ( NVL(TRUNC(fnd_date.canonical_to_date(:P_FROM_DATE)), xx.ORDERED_DATE) > xx.ordered_date  
       or  NVL(TRUNC(fnd_date.canonical_to_date(:P_TO_DATE)), xx.ORDERED_DATE) < xx.ordered_date )  
AND NVL(:P_CUSTOMER, xx.customer_id) = xx.customer_id 

在并发程序中,日期参数有FND_STANDARD_DATE。

1 个答案:

答案 0 :(得分:0)

有很多方法可以为这只特殊的猫提供皮肤,这只是一种方法。顺便提一下,在你的例子中,你给出了4月31日的日期,但这不存在。

GetPetDog();
GetPetCat();
GetPetBird();