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
|
* Function documentNofunc - PL/SQL equivalent to pljava SQLJ function
|
||||||
* Author: Tony Snook (tspc)
|
* Author: Tony Snook (tspc)
|
||||||
|
* Author: Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
AS
|
AS
|
||||||
v_DocumentNo pp_mrp.value%TYPE := '';
|
v_DocumentNo PP_MRP.Value%TYPE := '';
|
||||||
|
|
||||||
CURSOR cur
|
CURSOR cur_mrp IS
|
||||||
IS
|
|
||||||
SELECT ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id
|
SELECT ordertype, m_forecast_id, c_order_id, dd_order_id, pp_order_id, m_requisition_id
|
||||||
FROM pp_mrp
|
FROM pp_mrp
|
||||||
WHERE pp_mrp_id = p_pp_mrp_id;
|
WHERE pp_mrp_id = p_pp_mrp_id;
|
||||||
|
|
||||||
rec cur%ROWTYPE;
|
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
-- If NO id return null
|
-- If NO id return empty string
|
||||||
IF p_PP_MRP_ID = 0 THEN
|
IF p_PP_MRP_ID <= 0 THEN
|
||||||
CLOSE cur;
|
|
||||||
RETURN '';
|
RETURN '';
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
FOR cur IN cur_mrp LOOP
|
||||||
CASE
|
CASE
|
||||||
WHEN rec.ordertype = 'FTC' THEN
|
WHEN cur.ordertype = 'FTC' THEN
|
||||||
SELECT f.Name INTO v_DocumentNo FROM M_Forecast f WHERE f.M_Forecast_ID=rec.M_Forecast_ID;
|
SELECT f.Name INTO v_DocumentNo FROM M_Forecast f WHERE f.M_Forecast_ID=cur.M_Forecast_ID;
|
||||||
WHEN rec.ordertype = 'POO' THEN
|
WHEN cur.ordertype = 'POO' THEN
|
||||||
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=rec.C_Order_ID;
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
WHEN rec.ordertype = 'DOO' THEN
|
WHEN cur.ordertype = 'DOO' THEN
|
||||||
SELECT do.DocumentNo INTO v_DocumentNo FROM DD_Order DO WHERE do.DD_Order_ID=rec.DD_Order_ID;
|
SELECT do.DocumentNo INTO v_DocumentNo FROM DD_Order DO WHERE do.DD_Order_ID=cur.DD_Order_ID;
|
||||||
WHEN rec.ordertype = 'SOO' THEN
|
WHEN cur.ordertype = 'SOO' THEN
|
||||||
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=rec.C_Order_ID;
|
SELECT co.DocumentNo INTO v_DocumentNo FROM C_Order co WHERE co.C_Order_ID=cur.C_Order_ID;
|
||||||
WHEN rec.ordertype = 'MOP' THEN
|
WHEN cur.ordertype = 'MOP' THEN
|
||||||
SELECT po.DocumentNo INTO v_DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=rec.PP_Order_ID;
|
SELECT po.DocumentNo INTO v_DocumentNo FROM PP_Order po WHERE po.PP_Order_ID=cur.PP_Order_ID;
|
||||||
WHEN rec.ordertype = 'POR' THEN
|
WHEN cur.ordertype = 'POR' THEN
|
||||||
SELECT r.DocumentNo INTO v_DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=rec.M_Requisition_ID;
|
SELECT r.DocumentNo INTO v_DocumentNo FROM M_Requisition r WHERE r.M_Requisition_ID=cur.M_Requisition_ID;
|
||||||
ELSE
|
ELSE
|
||||||
v_documentno := '';
|
v_documentno := '';
|
||||||
END CASE;
|
END CASE;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
CLOSE cur;
|
|
||||||
--
|
|
||||||
RETURN v_DocumentNo;
|
RETURN v_DocumentNo;
|
||||||
END 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