oracle ebs/apps:表pa\u draft\u invoice\u details\u all中draft\u invoice\u num列的值为空如何取行?

nnvyjq4y  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(372)

我有以下疑问:

select 
    ppdid.EXPENDITURE_ITEM_ID, 
    ppdid.DRAFT_INVOICE_NUM,
    ppdid.BILL_AMOUNT,
    ppdid.CREATION_DATE,    
    ppeia.EXPENDITURE_ITEM_DATE, 
    pppa.SEGMENT1 PROJECT_NUMBER,    
    ppdia.DRAFT_INVOICE_NUM,
    ppdia.RA_INVOICE_NUMBER
from
    PA.PA_DRAFT_INVOICE_DETAILS_ALL ppdid,
    PA.PA_EXPENDITURE_ITEMS_ALL ppeia,
    PA.PA_PROJECTS_ALL pppa,
    PA.PA_DRAFT_INVOICES_ALL ppdia
where ppdid.EXPENDITURE_ITEM_ID = ppeia.EXPENDITURE_ITEM_ID
and   ppdid.PROJECT_ID          = pppa.PROJECT_ID
and   ppdid.PROJECT_ID          = ppdia.PROJECT_ID
--and ppdid.DRAFT_INVOICE_NUM = ppdia.DRAFT_INVOICE_NUM
and   (   ppdid.DRAFT_INVOICE_NUM = ppdia.DRAFT_INVOICE_NUM
       or ppdia.DRAFT_INVOICE_NUM = ppdid.ORIG_DRAFT_INVOICE_NUM
      )  
and   pppa.SEGMENT1 = '123456' --fictive number
and   ppdia.GL_PERIOD_NAME = '05-2020'
order by ppdid.DRAFT_INVOICE_NUM;

问题是在2020年4月创建的发票在2020年5月贷记。所有此类情况下的交易(不同月份的原始发票和信用发票,未重新发行)都不会通过查询获取,即使我取出 pppdia.GL_PERIOD_NAME 条件。
我试着把 (+) 在连接的不同一侧,但结果相同。
有什么办法解决这个问题吗?
谢谢,亚历克斯

yhqotfr8

yhqotfr81#

这是因为null不等于任何东西,包括另一个null。这将导致你的 predicate

and
--ppdid.DRAFT_INVOICE_NUM = ppdia.DRAFT_INVOICE_NUM
  (
  ppdid.DRAFT_INVOICE_NUM  = ppdia.DRAFT_INVOICE_NUM  or ppdia.DRAFT_INVOICE_NUM = ppdid.ORIG_DRAFT_INVOICE_NUM
  )

总是返回false,因此查询返回0行。将or添加到or列表中

and
--ppdid.DRAFT_INVOICE_NUM = ppdia.DRAFT_INVOICE_NUM
  (  ppdid.DRAFT_INVOICE_NUM = ppdia.DRAFT_INVOICE_NUM  
  or ppdia.DRAFT_INVOICE_NUM = ppdid.ORIG_DRAFT_INVOICE_NUM
  or ppdid.DRAFT_INVOICE_NUM is null
  )

相关问题