BF [ 2041299 ] DB Function "documentNo" is not working
This commit is contained in:
parent
811567c666
commit
6a93958932
|
@ -1,47 +1,44 @@
|
||||||
create or replace FUNCTION documentNo
|
create or replace FUNCTION documentNo
|
||||||
(
|
(
|
||||||
p_PP_MRP_ID IN pp_mrp.pp_mrp_id%TYPE DEFAULT 0)
|
p_PP_MRP_ID IN PP_MRP.PP_MRP_ID%TYPE
|
||||||
RETURN pp_mrp.value%TYPE
|
)
|
||||||
/*************************************************************************
|
RETURN PP_MRP.Value%TYPE
|
||||||
* Function documentNofunc - PL/SQL equivalent to pljava SQLJ function
|
/************************************************************************
|
||||||
* Author: Tony Snook (tspc)
|
* Function documentNofunc - PL/SQL equivalent to pljava SQLJ function
|
||||||
************************************************************************/
|
* Author: Tony Snook (tspc)
|
||||||
AS
|
* Author: Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
v_DocumentNo pp_mrp.value%TYPE := '';
|
************************************************************************/
|
||||||
|
AS
|
||||||
CURSOR cur
|
v_DocumentNo PP_MRP.Value%TYPE := '';
|
||||||
IS
|
|
||||||
SELECT ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id
|
CURSOR cur_mrp IS
|
||||||
FROM pp_mrp
|
SELECT ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id
|
||||||
WHERE pp_mrp_id = p_pp_mrp_id;
|
FROM pp_mrp
|
||||||
|
WHERE pp_mrp_id = p_pp_mrp_id;
|
||||||
rec cur%ROWTYPE;
|
BEGIN
|
||||||
|
-- If NO id return empty string
|
||||||
BEGIN
|
IF p_PP_MRP_ID <= 0 THEN
|
||||||
-- If NO id return null
|
RETURN '';
|
||||||
IF p_PP_MRP_ID = 0 THEN
|
END IF;
|
||||||
CLOSE cur;
|
|
||||||
RETURN '';
|
FOR cur IN cur_mrp LOOP
|
||||||
END IF;
|
CASE
|
||||||
|
WHEN cur.ordertype = 'FTC' THEN
|
||||||
CASE
|
SELECT f.Name INTO v_DocumentNo FROM M_Forecast f WHERE f.M_Forecast_ID=cur.M_Forecast_ID;
|
||||||
WHEN rec.ordertype = 'FTC' THEN
|
WHEN cur.ordertype = 'POO' THEN
|
||||||
SELECT f.Name INTO v_DocumentNo FROM M_Forecast f WHERE f.M_Forecast_ID=rec.M_Forecast_ID;
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
WHEN rec.ordertype = 'POO' THEN
|
WHEN cur.ordertype = 'DOO' THEN
|
||||||
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=rec.C_Order_ID;
|
SELECT do.DocumentNo INTO v_DocumentNo FROM DD_Order DO WHERE do.DD_Order_ID=cur.DD_Order_ID;
|
||||||
WHEN rec.ordertype = 'DOO' THEN
|
WHEN cur.ordertype = 'SOO' THEN
|
||||||
SELECT do.DocumentNo INTO v_DocumentNo FROM DD_Order DO WHERE do.DD_Order_ID=rec.DD_Order_ID;
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
WHEN rec.ordertype = 'SOO' THEN
|
WHEN cur.ordertype = 'MOP' THEN
|
||||||
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=rec.C_Order_ID;
|
SELECT po.DocumentNo INTO v_DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=cur.PP_Order_ID;
|
||||||
WHEN rec.ordertype = 'MOP' THEN
|
WHEN cur.ordertype = 'POR' THEN
|
||||||
SELECT po.DocumentNo INTO v_DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=rec.PP_Order_ID;
|
SELECT r.DocumentNo INTO v_DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=cur.M_Requisition_ID;
|
||||||
WHEN rec.ordertype = 'POR' THEN
|
ELSE
|
||||||
SELECT r.DocumentNo INTO v_DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=rec.M_Requisition_ID;
|
v_documentno := '';
|
||||||
ELSE
|
END CASE;
|
||||||
v_documentno := '';
|
END LOOP;
|
||||||
END CASE;
|
|
||||||
|
RETURN v_DocumentNo;
|
||||||
CLOSE cur;
|
END documentNo;
|
||||||
--
|
|
||||||
RETURN v_DocumentNo;
|
|
||||||
END documentNo;
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
create or replace FUNCTION documentNo
|
||||||
|
(
|
||||||
|
p_PP_MRP_ID IN PP_MRP.PP_MRP_ID%TYPE
|
||||||
|
)
|
||||||
|
RETURN PP_MRP.Value%TYPE
|
||||||
|
/************************************************************************
|
||||||
|
* Function documentNofunc - PL/SQL equivalent to pljava SQLJ function
|
||||||
|
* Author: Tony Snook (tspc)
|
||||||
|
* Author: Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
************************************************************************/
|
||||||
|
AS
|
||||||
|
v_DocumentNo PP_MRP.Value%TYPE := '';
|
||||||
|
|
||||||
|
CURSOR cur_mrp IS
|
||||||
|
SELECT ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id
|
||||||
|
FROM pp_mrp
|
||||||
|
WHERE pp_mrp_id = p_pp_mrp_id;
|
||||||
|
BEGIN
|
||||||
|
-- If NO id return empty string
|
||||||
|
IF p_PP_MRP_ID <= 0 THEN
|
||||||
|
RETURN '';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
FOR cur IN cur_mrp LOOP
|
||||||
|
CASE
|
||||||
|
WHEN cur.ordertype = 'FTC' THEN
|
||||||
|
SELECT f.Name INTO v_DocumentNo FROM M_Forecast f WHERE f.M_Forecast_ID=cur.M_Forecast_ID;
|
||||||
|
WHEN cur.ordertype = 'POO' THEN
|
||||||
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
|
WHEN cur.ordertype = 'DOO' THEN
|
||||||
|
SELECT do.DocumentNo INTO v_DocumentNo FROM DD_Order DO WHERE do.DD_Order_ID=cur.DD_Order_ID;
|
||||||
|
WHEN cur.ordertype = 'SOO' THEN
|
||||||
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
|
WHEN cur.ordertype = 'MOP' THEN
|
||||||
|
SELECT po.DocumentNo INTO v_DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=cur.PP_Order_ID;
|
||||||
|
WHEN cur.ordertype = 'POR' THEN
|
||||||
|
SELECT r.DocumentNo INTO v_DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=cur.M_Requisition_ID;
|
||||||
|
ELSE
|
||||||
|
v_documentno := '';
|
||||||
|
END CASE;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RETURN v_DocumentNo;
|
||||||
|
END documentNo;
|
|
@ -0,0 +1 @@
|
||||||
|
-- Placeholder
|
Loading…
Reference in New Issue