Advertisement
tko_pb

ret_background_tr_post

Mar 20th, 2019
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION public.ret_background_tr_post()
  2.  RETURNS void
  3.  LANGUAGE plpgsql
  4.  SET search_path TO '$user', 'public'
  5. AS $function$ DECLARE
  6. /*************************************************************************
  7. * Contributor(s): AHMAD HADI NUGROHO
  8. ************************************************************************/
  9.   -- Logistice
  10.   v_ResultStr VARCHAR(4000):=''; --OBTG:VARCHAR2--
  11.   v_Record_ID VARCHAR(32); --OBTG:VARCHAR2--
  12.   v_User_ID VARCHAR(32);
  13.   v_Client_ID VARCHAR(32) ; --OBTG:VARCHAR2--
  14.   v_Org_ID VARCHAR(32); --OBTG:VARCHAR2--
  15.   v_Count NUMERIC;
  16.   v_AD_Pinstance_ID VARCHAR(32); --OBTG:VARCHAR2--
  17.  
  18.   --  Parameter
  19.   --TYPE RECORD IS REFCURSOR;
  20.   Cur_TransferRequest RECORD;
  21.   Cur_Parameter RECORD;
  22.  
  23. BEGIN
  24. BEGIN --BODY
  25.  
  26.     -- Get Parameters
  27.     v_ResultStr:='ReadingParameters';
  28.     FOR Cur_Parameter IN
  29.       (SELECT i.Record_ID,
  30.         i.AD_User_ID,
  31.         p.ParameterName,
  32.         p.P_String,
  33.         p.P_Number,
  34.         p.P_Date,
  35.         p.AD_Org_ID,
  36.         p.AD_Client_ID
  37.       FROM AD_PInstance i
  38.       LEFT JOIN AD_PInstance_Para p
  39.         ON i.AD_PInstance_ID=p.AD_PInstance_ID
  40.       WHERE i.AD_PInstance_ID=p_PInstance_ID
  41.       ORDER BY p.SeqNo
  42.       )
  43.     LOOP
  44.       v_Record_ID:= Cur_Parameter.Record_ID;
  45.       v_User_ID:= Cur_Parameter.AD_User_ID;
  46.       v_Org_ID:= Cur_Parameter.AD_Org_ID;
  47.     END LOOP; -- Get Parameter
  48. --    RAISE NOTICE '%','  Record_ID=' || v_Record_ID ;
  49.    
  50.   FOR Cur_TransferRequest IN (select m.m_movement_id
  51.     from m_movement m
  52.         where m.em_oez_is_tranfer_request ='Y'
  53.             and m.ad_client_id = '9FEF116B9BA24538AC481B809CC750FF'
  54.             and m.em_oez_docstatus = 'DR'
  55. --              and m.ad_org_id = v_Org_ID
  56.             order by documentno asc
  57.   ) LOOP
  58.    
  59.     perform ret_transfer_request_post(p_pinstance_id, Cur_TransferRequest.m_movement_id);
  60.  
  61.   END LOOP;
  62.  
  63.  
  64. END; --BODY
  65. EXCEPTION
  66. WHEN OTHERS THEN
  67.   RAISE NOTICE '%','Background process exception: ' || v_ResultStr;
  68.   RAISE EXCEPTION '%', SQLERRM;
  69. --  RETURN;
  70. END ; $function$
  71. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement