src-db/database/model/functions/M_UPDATE_PARETO_PRODUCT.xml
changeset 1605 8a0fe0193bef
parent 1273 3f48377a0023
child 1684 916be19be567
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2   <database name="FUNCTION M_UPDATE_PARETO_PRODUCT">
     2   <database name="FUNCTION M_UPDATE_PARETO_PRODUCT">
     3     <function name="M_UPDATE_PARETO_PRODUCT" type="NULL">
     3     <function name="M_UPDATE_PARETO_PRODUCT" type="NULL">
     4       <parameter name="p_pinstance_id" type="NUMERIC" mode="in">
     4       <parameter name="p_pinstance_id" type="VARCHAR" mode="in">
     5         <default/>
     5         <default/>
     6       </parameter>
     6       </parameter>
     7       <parameter name="p_warehouse_id" type="NUMERIC" mode="in">
     7       <parameter name="p_warehouse_id" type="VARCHAR" mode="in">
     8         <default/>
     8         <default/>
     9       </parameter>
     9       </parameter>
    10       <parameter name="p_org_id" type="NUMERIC" mode="in">
    10       <parameter name="p_org_id" type="VARCHAR" mode="in">
    11         <default/>
    11         <default/>
    12       </parameter>
    12       </parameter>
    13       <body><![CDATA[/*************************************************************************
    13       <body><![CDATA[/*************************************************************************
    14 * The contents of this file are subject to the Openbravo  Public  License
    14 * The contents of this file are subject to the Openbravo  Public  License
    15 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
    15 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
    29 
    29 
    30   v_ResultStr VARCHAR2(2000):='';
    30   v_ResultStr VARCHAR2(2000):='';
    31   v_Result NUMBER:= 1;
    31   v_Result NUMBER:= 1;
    32   v_Message VARCHAR2(2000):='';
    32   v_Message VARCHAR2(2000):='';
    33   v_exist NUMBER:=0;
    33   v_exist NUMBER:=0;
    34   v_M_Product_Org_ID NUMBER(10);
    34   v_M_Product_Org_ID VARCHAR2(32);
    35   v_warehouse_ID NUMBER(10);
    35   v_warehouse_ID VARCHAR2(32);
    36   v_org_ID NUMBER(10);
    36   v_org_ID VARCHAR2(32);
    37   v_count_update NUMBER:= 0;
    37   v_count_update NUMBER:= 0;
    38   v_count_insert NUMBER:= 0;
    38   v_count_insert NUMBER:= 0;
    39   TYPE RECORD IS REF CURSOR;
    39   TYPE RECORD IS REF CURSOR;
    40   Cur_Cursor RECORD;
    40   Cur_Cursor RECORD;
    41   Cur_Parameter RECORD;
    41   Cur_Parameter RECORD;
    42   v_AD_Client_ID NUMBER;
    42   v_AD_Client_ID VARCHAR2(32);
    43 BEGIN
    43 BEGIN
    44 
    44 
    45   IF(p_PInstance_ID IS NOT NULL) THEN
    45   IF(p_PInstance_ID IS NOT NULL) THEN
    46       --  Update AD_PInstance
    46       --  Update AD_PInstance
    47       DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
    47       DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
   119        AND AD_ORG_ID = Cur_Cursor.AD_ORG_ID;
   119        AND AD_ORG_ID = Cur_Cursor.AD_ORG_ID;
   120        v_count_update := v_count_update + 1;
   120        v_count_update := v_count_update + 1;
   121      ELSE
   121      ELSE
   122        AD_Sequence_Next('M_Product_Org', Cur_Cursor.AD_CLIENT_ID, v_M_Product_Org_ID) ;
   122        AD_Sequence_Next('M_Product_Org', Cur_Cursor.AD_CLIENT_ID, v_M_Product_Org_ID) ;
   123        INSERT INTO M_PRODUCT_ORG (M_PRODUCT_ORG_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, M_PRODUCT_ID, ABC) VALUES
   123        INSERT INTO M_PRODUCT_ORG (M_PRODUCT_ORG_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, M_PRODUCT_ID, ABC) VALUES
   124        (v_M_Product_Org_ID, Cur_Cursor.AD_CLIENT_ID, Cur_Cursor.AD_ORG_ID, 'Y', now(), 100, now(), 100, Cur_Cursor.M_PRODUCT_ID, Cur_Cursor.ISABC);
   124        (v_M_Product_Org_ID, Cur_Cursor.AD_CLIENT_ID, Cur_Cursor.AD_ORG_ID, 'Y', now(), '100', now(), '100', Cur_Cursor.M_PRODUCT_ID, Cur_Cursor.ISABC);
   125        v_count_insert := v_count_insert + 1;
   125        v_count_insert := v_count_insert + 1;
   126      END IF;
   126      END IF;
   127 
   127 
   128   end loop;
   128   end loop;
   129   v_Message:='@Created@=' || v_count_insert || ', @Updated@=' || v_count_update;
   129   v_Message:='@Created@=' || v_count_insert || ', @Updated@=' || v_count_update;