src-db/database/model/triggers/M_TRANSACTION_TRG.xml
changeset 1605 8a0fe0193bef
parent 1261 0e35cc0084db
child 2078 cf88ca44cdd2
equal deleted inserted replaced
1604:a1c518e6ed93 1605:8a0fe0193bef
    21 * All portions are Copyright (C) 2001-2006 Openbravo SL
    21 * All portions are Copyright (C) 2001-2006 Openbravo SL
    22 * All Rights Reserved.
    22 * All Rights Reserved.
    23 * Contributor(s):  ______________________________________.
    23 * Contributor(s):  ______________________________________.
    24 ************************************************************************/
    24 ************************************************************************/
    25   v_DATEINVENTORY DATE;
    25   v_DATEINVENTORY DATE;
    26   v_UOM_ID NUMBER(10) ;
    26   v_UOM_ID VARCHAR2(32) ;
    27   v_ATTRIBUTESET_ID NUMBER(10);
    27   v_ATTRIBUTESET_ID VARCHAR2(32);
    28   v_Name NVARCHAR2(60);
    28   v_Name NVARCHAR2(60);
    29 BEGIN
    29 BEGIN
    30   IF INSERTING OR UPDATING THEN
    30   IF INSERTING OR UPDATING THEN
    31     SELECT C_UOM_ID, M_ATTRIBUTESET_ID, name
    31     SELECT C_UOM_ID, M_ATTRIBUTESET_ID, name
    32     INTO v_UOM_ID, v_attributeset_id, v_name
    32     INTO v_UOM_ID, v_attributeset_id, v_name
    33     FROM M_PRODUCT
    33     FROM M_PRODUCT
    34     WHERE M_PRODUCT_ID=:NEW.M_PRODUCT_ID;
    34     WHERE M_PRODUCT_ID=:NEW.M_PRODUCT_ID;
    35     IF(COALESCE(v_UOM_ID, 0) <> COALESCE(:NEW.C_UOM_ID, 0)) THEN
    35     IF(COALESCE(v_UOM_ID, '0') <> COALESCE(:NEW.C_UOM_ID, '0')) THEN
    36       RAISE_APPLICATION_ERROR(-20111, 'Unit of Measure mismatch (product/transaction)') ;
    36       RAISE_APPLICATION_ERROR(-20111, 'Unit of Measure mismatch (product/transaction)') ;
    37     END IF;
    37     END IF;
    38     IF(v_attributeset_id IS NOT NULL AND COALESCE(:NEW.M_ATTRIBUTESETINSTANCE_ID, 0) = 0) THEN
    38     IF(v_attributeset_id IS NOT NULL AND COALESCE(:NEW.M_ATTRIBUTESETINSTANCE_ID, '0') = '0') THEN
    39       RAISE_APPLICATION_ERROR(-20112, 'There are some products without attribute: ' || v_Name) ;
    39       RAISE_APPLICATION_ERROR(-20112, 'There are some products without attribute: ' || v_Name) ;
    40     END IF;
    40     END IF;
    41     SELECT MAX(MOVEMENTDATE)
    41     SELECT MAX(MOVEMENTDATE)
    42     INTO v_DATEINVENTORY
    42     INTO v_DATEINVENTORY
    43     FROM M_INVENTORY I,
    43     FROM M_INVENTORY I,