如何发送已发送的数据?

时间:2017-11-08 21:36:29

标签: oracle oracle-sqldeveloper

我希望有人可以在我迷路的时候提供帮助。我每天多次向客户发送一个文件,其中包含多个采购订单编号,每个文件每次都包含不同的采购订单#。我有一个名为EDICUSTOUTBOUND_810_SENT的表,每次发送订单时都会使用PO#进行更新,以确保我不发送重复项。偶尔,PO#将在文件之间分开,这会给客户带来问题。发生这种情况时我想要做的是包括前一个文件中PO#的所有项目以及第二个文件中的新项目。自从我更新发送的表后,我无法弄清楚如何做到这一点。我现在忽略了已发送的表,只是发送每个运行的所有内容。 EDICUSTOUTBOUND_810_SENT

SELECT 'TAG' as RECORD_TAG,
   'ASN' as DOC_TYPE,
   'CDS' as TPID,
   'RMA' as PARENT_CHAIN,
   To_char(ORD.sched_date, 'MM/DD/YYYY')              SCHEDULE_DATE, 
   CST.ship_city                                      FACILITY_CITY,
   CST.ship_state                                     FACILITY_STATE,
   ORD.po_number || '-' || ORD.CUST_NBR               ASN_ID, 
   SD.route_seq || To_char(SD.load_date, 'DDMMYY')    MANIFEST, 
   SD.order_number                                    ORDER_NUMBER,
   SD.ROUTE_SEQ                                       ROUTE_SEQ, 
   SD.LOAD_DATE                                       LOADDATE,
   ORD.CUST_NBR                                       CUST_NBR, 
   ORD.po_number                                      PO_NUM, 
   REPLACE(ORD.contractor, ',', ' ')                  JOB_NAME,
   SD.line_item                                       LINE_ITEM, 
   SD.sub_item                                        SUB_ITEM, 
   CASE WHEN DET.item_qty  > 1 THEN '1' ELSE CAST (DET.item_qty AS VARCHAR2(20))
   END QTY,
   SD.barcode                                         BARCODE,
   DET.prod_line                                      LN, 
   DET.prod_style                                     ST, 
   SD.unit_type                                       WINDOW_PART, 
   REPLACE(SD.okopt_desc, ',', ' ')                   DESCRIPTION

FROM(

        SELECT DISTINCT manifest

        FROM (SELECT manifest, order_number
              FROM wsoe.shippingdata
              WHERE load_date >= trunc(sysdate) AND CURPROCESSID = 210  ) sd1   

        JOIN wsoe.ordhead oh1 ON sd1.order_number = oh1.order_number
        LEFT JOIN WSOE.EDICUSTOUTBOUND_810_SENT edi ON oh1.po_number || '-' || oh1.CUST_NBR  = edi.invoice_no
        WHERE edi.invoice_no IS NULL      
   ) m 
   JOIN wsoe.shippingdata sd ON sd.manifest = m.manifest
   JOIN wsoe.ordhead ORD 
     ON SD.order_number = ORD.order_number 
   JOIN wsoe.orddet DET 
     ON DET.order_number = SD.order_number 
        AND DET.line_item = SD.line_item 
        AND DET.sub_item = SD.sub_item 
   JOIN wsoe.customer CST 
     ON CST.cust_nbr = ORD.cust_nbr 
   WHERE Substr(CST.custflags, 60, 1) = 'Y'
       ORDER BY po_num, line_item;

1 个答案:

答案 0 :(得分:0)

听起来你真正的问题是有时PO#会在文件之间分裂。最好的解决方案是确保首先不会发生这种情况。你受文件大小限制吗?您可以更改实际将记录转储到要发送的文件的其他代码,以测量下一条记录的大小,并确定它是否适合当前文件。

如果您知道需要重新发送哪个PO#,那么您应该能够更改内部查询以获取特定的PO#。像

这样的东西
...
JOIN wsoe.ordhead oh1 ON sd1.order_number = oh1.order_number
    LEFT JOIN WSOE.EDICUSTOUTBOUND_810_SENT edi ON oh1.po_number || '-' || oh1.CUST_NBR = edi.invoice_no
    WHERE edi.invoice_no IS NULL OR oh1.po_number = 80
...

在下一次运行中包含采购订单编号80.