SQL 错误 [903] [42000]: ORA-00903: 表名无效
Error : 903, Position : 2432, SQL = -- AX_OMP2024.V_ORDER_TRACK source
CREATE OR REPLACE FORCE VIEW "AX_OMP2024"."V_ORDER_TRACK" ("ID", "FOFFERNUM", "FCCONTACTDATE", "FSELLER", "FSELLERNAME", "FCUSTOMNAME", "FCUSTOMERNUM", "FPRODUCTMODEL", "FQUANTITY", "FSEGMENTDESCRIPTION", "FORIGINALPRICETAX", "FORIGINALTOTALPRICETAX", "FDELIVERYDATEPLAN", "FOEMFLAG", "FNEEDPRODUCT", "FSTATUS", "FCONTRACTTYPE", "FITEMCHOOSE", "FDESCRIPTION", "FCUSTOMERMODEL", "FLINEID", "FUNIQUELINEID", "FERPLINENUMBER", "SUM_LEN_COMM_STORE", "SUM_SHIP_QTY", "SUM_INVOICE_QTY", "PRE_INVOICE_QTY","FLASTFHDATE", "SUM_LEN_COMM_OUT", "ISSHIPDONE", "ISPRODUCTDONE", "STOREAGE", "ITEM_CORE") AS
with t_wms as (
select in_order_no, item_no, sum(t.len_comm) sum_len_comm_store
from T_in_store_cab_from_WMS901 t where t.status = '在库' group by in_order_no, item_no
),
t_wms_out as (--本地
--select in_order_no, item_no, sum(t.len_comm) sum_len_comm_out
--from T_in_store_cab_from_WMS901 t where t.status = '已出库' group by in_order_no, item_no
select FContractNo in_order_no, ITEM_CODE item_no, ERPLineNumber order_line_number,
sum(t.quantity) sum_len_comm_out, max(TRANSACTION_DATE) TRANSACTION_DATE
from T_OMP_Store_Out t where t.ftype = 1 group by t.FContractNo, t.ITEM_CODE, ERPLineNumber
),
t_po_out as(--外协出库
select FContractNo in_order_no, ITEM_CODE item_no, ERPLineNumber order_line_number,
sum(t.quantity) sum_len_comm_out, max(TRANSACTION_DATE) TRANSACTION_DATE
from T_OMP_Store_Out t where t.ftype = 2 group by t.FContractNo, t.ITEM_CODE, t.ERPLineNumber
),
t_ship as(
select a.header_id, a.crm_line_number, sum(a.FApplyQuantity) sum_ship_qty from T_CRM_Delivery_Order_F a
left join T_CRM_Delivery_Order b on a.t_crm_delivery_order_id = b.id where b.fstatus != -99
group by a.header_id, a.crm_line_number
),
t_invoice as(
select sum(t.FInvoiceQTY) sum_invoice_qty, t.FOrderHeadId, t.FUniqueLineID
from T_CRM_INVOICE_LINETY t, T_CRM_INVOICE_HEADTY t1
where t.T_CRM_INVOICE_HEADTY_id = t1.id and t1.FState =100 and t1.fapplyType != 1
group by t.FOrderHeadId, t.FUniqueLineID
),
t_invoice_pre as(
select sum(t.FInvoiceQTY) sum_invoice_qty, t.FOrderHeadId, t.FUniqueLineID
from T_CRM_INVOICE_LINETY t, T_CRM_INVOICE_HEADTY t1
where t.T_CRM_INVOICE_HEADTY_id = t1.id and t1.FState = 90 and t1.fapplyType = 1
group by t.FOrderHeadId, t.FUniqueLineID
),
with t_wms_details as (
SELECT MAX(TT.OUT_TIME) ,tt.IN_ORDER_NO ,TT.ITEM_NO FROM SV_WMS_SHIP_DETAILS tt
GROUP BY tt.IN_ORDER_NO ,TT.ITEM_NO
)
select DISTINCT a.id, b.foffernum, b.fccontactdate,b.fseller, i.name fsellerName, h.fcompanyname fcustomname, b.fcustomernum,
a.fproductmodel, a.fquantity, a.fsegmentdescription, round(a.FOriginalPriceTax, 4) FOriginalPriceTax, a.FOriginalTotalPriceTax,
a.FDeliveryDatePlan, a.FOEMFlag, a.FNeedProduct,
b.fstatus, b.fcontracttype, c.item_code fitemchoose, c.item_desc FDescription, a.FCustomerModel,
a.flineid, a.funiquelineid, a.FERPLineNumber, d.sum_len_comm_store, e.sum_ship_qty,--发货指令数量
f.sum_invoice_qty, g.sum_invoice_qty pre_invoice_qty,
tw.OUT_TIME,
--decode(a.FOEMFlag, 1, d2.sum_len_comm_out, d1.sum_len_comm_out)sum_len_comm_out,
--(nvl(d2.sum_len_comm_out, 0) + nvl(d1.sum_len_comm_out, 0)) sum_len_comm_out,
(nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0)) + nvl(d1.sum_len_comm_out, 0)) sum_len_comm_out,
case when ((nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0))+ nvl(d1.sum_len_comm_out, 0))) >= a.fquantity then 'Y' else 'N' end isShipDone,
case when (nvl(d.sum_len_comm_store, 0) + (nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0)) + nvl(d1.sum_len_comm_out, 0)) ) >= a.fquantity then 'Y' else 'N' end isProductDone,
--发货数量大于开票数量才计算库龄
case when (nvl(e.sum_ship_qty, 0) - nvl(f.sum_invoice_qty, 0)) > 0 then round(sysdate - nvl(d1.TRANSACTION_DATE, d2.TRANSACTION_DATE), 0) end storeAge,
TO_NUMBER(SUBSTR(c.item_code, 8, 4)) item_core
from T_CRM_Orders_FDetail a
left join T_CRM_Orders b on a.T_CRM_Orders_id = b.id
left join T_ITEM_Info c on c.ids = a.fitemchoose
left join t_wms d on d.in_order_no = b.foffernum and c.item_code = d.item_no
--本地生产
left join t_wms_out d1 on d1.in_order_no = b.foffernum and c.item_code = d1.item_no and d1.order_line_number = a.FERPLineNumber
left join t_po_out d2 on d2.in_order_no||'' = b.foffernum and c.item_code = d2.item_no --and d2.order_line_number = a.FERPLineNumber
-- and (d2.order_line_number is null or (d2.order_line_number is not null and d2.order_line_number = a.FERPLineNumber)) --太慢了
left join t_po_out d3 on d3.in_order_no||'' = b.foffernum and c.item_code = d3.item_no and d3.order_line_number = a.FERPLineNumber
left join t_ship e on e.header_id = b.FHeaderID and e.crm_line_number = a.funiquelineid
left join t_invoice f on f.FOrderHeadId = b.id and f.FUniqueLineID = a.funiquelineid
left join t_invoice_pre g on g.FOrderHeadId = b.id and g.FUniqueLineID = a.funiquelineid
left join t_crm_customer h on h.id = b.fcustomname
left join tuser i on i.id = b.FSeller
left join t_wms_details tw ON tw.IN_ORDER_NO = b.foffernum AND tw.ITEM_NO = c.item_code
where b.fcontracttype != 10008, Original SQL = -- AX_OMP2024.V_ORDER_TRACK source
CREATE OR REPLACE FORCE VIEW "AX_OMP2024"."V_ORDER_TRACK" ("ID", "FOFFERNUM", "FCCONTACTDATE", "FSELLER", "FSELLERNAME", "FCUSTOMNAME", "FCUSTOMERNUM", "FPRODUCTMODEL", "FQUANTITY", "FSEGMENTDESCRIPTION", "FORIGINALPRICETAX", "FORIGINALTOTALPRICETAX", "FDELIVERYDATEPLAN", "FOEMFLAG", "FNEEDPRODUCT", "FSTATUS", "FCONTRACTTYPE", "FITEMCHOOSE", "FDESCRIPTION", "FCUSTOMERMODEL", "FLINEID", "FUNIQUELINEID", "FERPLINENUMBER", "SUM_LEN_COMM_STORE", "SUM_SHIP_QTY", "SUM_INVOICE_QTY", "PRE_INVOICE_QTY","FLASTFHDATE", "SUM_LEN_COMM_OUT", "ISSHIPDONE", "ISPRODUCTDONE", "STOREAGE", "ITEM_CORE") AS
with t_wms as (
select in_order_no, item_no, sum(t.len_comm) sum_len_comm_store
from T_in_store_cab_from_WMS901 t where t.status = '在库' group by in_order_no, item_no
),
t_wms_out as (--本地
--select in_order_no, item_no, sum(t.len_comm) sum_len_comm_out
--from T_in_store_cab_from_WMS901 t where t.status = '已出库' group by in_order_no, item_no
select FContractNo in_order_no, ITEM_CODE item_no, ERPLineNumber order_line_number,
sum(t.quantity) sum_len_comm_out, max(TRANSACTION_DATE) TRANSACTION_DATE
from T_OMP_Store_Out t where t.ftype = 1 group by t.FContractNo, t.ITEM_CODE, ERPLineNumber
),
t_po_out as(--外协出库
select FContractNo in_order_no, ITEM_CODE item_no, ERPLineNumber order_line_number,
sum(t.quantity) sum_len_comm_out, max(TRANSACTION_DATE) TRANSACTION_DATE
from T_OMP_Store_Out t where t.ftype = 2 group by t.FContractNo, t.ITEM_CODE, t.ERPLineNumber
),
t_ship as(
select a.header_id, a.crm_line_number, sum(a.FApplyQuantity) sum_ship_qty from T_CRM_Delivery_Order_F a
left join T_CRM_Delivery_Order b on a.t_crm_delivery_order_id = b.id where b.fstatus != -99
group by a.header_id, a.crm_line_number
),
t_invoice as(
select sum(t.FInvoiceQTY) sum_invoice_qty, t.FOrderHeadId, t.FUniqueLineID
from T_CRM_INVOICE_LINETY t, T_CRM_INVOICE_HEADTY t1
where t.T_CRM_INVOICE_HEADTY_id = t1.id and t1.FState =100 and t1.fapplyType != 1
group by t.FOrderHeadId, t.FUniqueLineID
),
t_invoice_pre as(
select sum(t.FInvoiceQTY) sum_invoice_qty, t.FOrderHeadId, t.FUniqueLineID
from T_CRM_INVOICE_LINETY t, T_CRM_INVOICE_HEADTY t1
where t.T_CRM_INVOICE_HEADTY_id = t1.id and t1.FState = 90 and t1.fapplyType = 1
group by t.FOrderHeadId, t.FUniqueLineID
),
with t_wms_details as (
SELECT MAX(TT.OUT_TIME) ,tt.IN_ORDER_NO ,TT.ITEM_NO FROM SV_WMS_SHIP_DETAILS tt
GROUP BY tt.IN_ORDER_NO ,TT.ITEM_NO
)
select DISTINCT a.id, b.foffernum, b.fccontactdate,b.fseller, i.name fsellerName, h.fcompanyname fcustomname, b.fcustomernum,
a.fproductmodel, a.fquantity, a.fsegmentdescription, round(a.FOriginalPriceTax, 4) FOriginalPriceTax, a.FOriginalTotalPriceTax,
a.FDeliveryDatePlan, a.FOEMFlag, a.FNeedProduct,
b.fstatus, b.fcontracttype, c.item_code fitemchoose, c.item_desc FDescription, a.FCustomerModel,
a.flineid, a.funiquelineid, a.FERPLineNumber, d.sum_len_comm_store, e.sum_ship_qty,--发货指令数量
f.sum_invoice_qty, g.sum_invoice_qty pre_invoice_qty,
tw.OUT_TIME,
--decode(a.FOEMFlag, 1, d2.sum_len_comm_out, d1.sum_len_comm_out)sum_len_comm_out,
--(nvl(d2.sum_len_comm_out, 0) + nvl(d1.sum_len_comm_out, 0)) sum_len_comm_out,
(nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0)) + nvl(d1.sum_len_comm_out, 0)) sum_len_comm_out,
case when ((nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0))+ nvl(d1.sum_len_comm_out, 0))) >= a.fquantity then 'Y' else 'N' end isShipDone,
case when (nvl(d.sum_len_comm_store, 0) + (nvl(d3.sum_len_comm_out, nvl(d2.sum_len_comm_out, 0)) + nvl(d1.sum_len_comm_out, 0)) ) >= a.fquantity then 'Y' else 'N' end isProductDone,
--发货数量大于开票数量才计算库龄
case when (nvl(e.sum_ship_qty, 0) - nvl(f.sum_invoice_qty, 0)) > 0 then round(sysdate - nvl(d1.TRANSACTION_DATE, d2.TRANSACTION_DATE), 0) end storeAge,
TO_NUMBER(SUBSTR(c.item_code, 8, 4)) item_core
from T_CRM_Orders_FDetail a
left join T_CRM_Orders b on a.T_CRM_Orders_id = b.id
left join T_ITEM_Info c on c.ids = a.fitemchoose
left join t_wms d on d.in_order_no = b.foffernum and c.item_code = d.item_no
--本地生产
left join t_wms_out d1 on d1.in_order_no = b.foffernum and c.item_code = d1.item_no and d1.order_line_number = a.FERPLineNumber
left join t_po_out d2 on d2.in_order_no||'' = b.foffernum and c.item_code = d2.item_no --and d2.order_line_number = a.FERPLineNumber
-- and (d2.order_line_number is null or (d2.order_line_number is not null and d2.order_line_number = a.FERPLineNumber)) --太慢了
left join t_po_out d3 on d3.in_order_no||'' = b.foffernum and c.item_code = d3.item_no and d3.order_line_number = a.FERPLineNumber
left join t_ship e on e.header_id = b.FHeaderID and e.crm_line_number = a.funiquelineid
left join t_invoice f on f.FOrderHeadId = b.id and f.FUniqueLineID = a.funiquelineid
left join t_invoice_pre g on g.FOrderHeadId = b.id and g.FUniqueLineID = a.funiquelineid
left join t_crm_customer h on h.id = b.fcustomname
left join tuser i on i.id = b.FSeller
left join t_wms_details tw ON tw.IN_ORDER_NO = b.foffernum AND tw.ITEM_NO = c.item_code
where b.fcontracttype != 10008, Error Message = ORA-00903: 表名无效
ORA-00903: 表名无效