src-db/database/model/triggers/S_RESOURCE_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 781 d68cf344696f
child 799 fef2c5e2feb7
permissions -rw-r--r--
Fix last update of copyright years in database files
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER S_RESOURCE_TRG">
adrian@94
     3
    <trigger name="S_RESOURCE_TRG" table="S_RESOURCE" fires="after" insert="true" update="true" delete="false" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
juanpablo@771
     5
    /*************************************************************************
juanpablo@771
     6
    * The contents of this file are subject to the Compiere Public
juanpablo@771
     7
    * License 1.1 ("License"); You may not use this file except in
juanpablo@771
     8
    * compliance with the License. You may obtain a copy of the License in
juanpablo@771
     9
    * the legal folder of your Openbravo installation.
adrian@94
    10
    * Software distributed under the License is distributed on an
adrian@94
    11
    * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
adrian@94
    12
    * implied. See the License for the specific language governing rights
adrian@94
    13
    * and limitations under the License.
juanpablo@778
    14
    * The Original Code is  Compiere  ERP &  Business Solution
juanpablo@771
    15
    * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
adrian@94
    16
    * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
adrian@94
    17
    * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
adrian@94
    18
    * All Rights Reserved.
adrian@94
    19
    * Contributor(s): Openbravo SL
juanpablo@785
    20
    * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
juanpablo@771
    21
    *
juanpablo@771
    22
    * Specifically, this derivative work is based upon the following Compiere
juanpablo@771
    23
    * file and version.
adrian@94
    24
    *************************************************************************
adrian@94
    25
    * $Id: S_Resource_Trg.sql,v 1.2 2002/10/23 03:16:57 jjanke Exp $
adrian@94
    26
    ***
adrian@94
    27
    * Title: S_Resource
adrian@94
    28
    * Description:
adrian@94
    29
    *   Syncronize Resource with Product
adrian@94
    30
    ************************************************************************/
adrian@94
    31
    NextNo M_Product.M_Product_ID%TYPE;
adrian@94
    32
  v_C_UOM_ID              M_Product.C_UOM_ID%TYPE;
adrian@94
    33
  v_M_Product_Category_ID M_Product.M_Product_Category_ID%TYPE;
adrian@94
    34
  v_C_TaxCategory_ID      M_Product.C_TaxCategory_ID%TYPE;
adrian@94
    35
BEGIN
adrian@94
    36
  IF(INSERTING) THEN
adrian@94
    37
    -- Get ResourceType Info
adrian@94
    38
    SELECT C_UOM_ID,
adrian@94
    39
      M_Product_Category_ID,
adrian@94
    40
      C_TaxCategory_ID
adrian@94
    41
    INTO v_C_UOM_ID,
adrian@94
    42
      v_M_Product_Category_ID,
adrian@94
    43
      v_C_TaxCategory_ID
adrian@94
    44
    FROM S_ResourceType
adrian@94
    45
    WHERE S_ResourceType_ID=:new.S_ResourceType_ID;
adrian@94
    46
    --
adrian@94
    47
    AD_Sequence_Next('M_Product', :new.AD_Client_ID, NextNo) ;
adrian@94
    48
    INSERT
adrian@94
    49
    INTO M_PRODUCT
adrian@94
    50
      (
adrian@94
    51
        M_Product_ID, AD_Client_ID, AD_Org_ID,
adrian@94
    52
        IsActive, Created, CreatedBy,
adrian@94
    53
        Updated, UpdatedBy, Value,
adrian@94
    54
        Name, Description, DOCUMENTNOTE,
adrian@94
    55
        HELP, UPC, SKU,
adrian@94
    56
        C_UOM_ID, SALESREP_ID, ISSUMMARY,
adrian@94
    57
        ProductType, ISSTOCKED, ISPURCHASED,
adrian@94
    58
        ISSOLD, ISBOM, ISINVOICEPRINTDETAILS,
adrian@94
    59
        ISPICKLISTPRINTDETAILS, ISVERIFIED, C_REVENUERECOGNITION_ID,
adrian@94
    60
        M_Product_Category_ID, CLASSIFICATION, VOLUME,
adrian@94
    61
        WEIGHT, SHELFWIDTH, SHELFHEIGHT,
adrian@94
    62
        SHELFDEPTH, UNITSPERPALLET, C_TaxCategory_ID,
adrian@94
    63
        S_Resource_ID, S_EXPENSETYPE_ID, DISCONTINUED,
adrian@94
    64
        DISCONTINUEDBY
adrian@94
    65
      )
adrian@94
    66
      VALUES
adrian@94
    67
      (
adrian@94
    68
        NextNo, :new.AD_Client_ID, :new.AD_Org_ID,
adrian@94
    69
        :new.IsActive, :new.Created, :new.CreatedBy,
adrian@94
    70
        :new.Updated, :new.UpdatedBy, :new.Value,
adrian@94
    71
        :new.Name, :new.Description, null,
adrian@94
    72
        null, null, null,
adrian@94
    73
        v_C_UOM_ID, null,  'N',
adrian@94
    74
         'R',  'N',  'N',
adrian@94
    75
         'Y', 'N', 'N',
adrian@94
    76
         'N', 'N', null,
adrian@94
    77
        v_M_Product_Category_ID, null, 0,
adrian@94
    78
        0, 0, 0,
adrian@94
    79
        0, 0, v_C_TaxCategory_ID,
adrian@94
    80
        :new.S_Resource_ID, null, 'N',
adrian@94
    81
        null
adrian@94
    82
      )
adrian@94
    83
      ;
adrian@94
    84
  ELSIF(UPDATING) THEN
adrian@94
    85
    UPDATE M_Product
adrian@94
    86
      SET IsActive=:new.IsActive,
adrian@94
    87
      Updated=:new.Updated,
adrian@94
    88
      UpdatedBy=:new.UpdatedBy,
adrian@94
    89
      Value=:new.Value,
adrian@94
    90
      Name=:new.Name,
adrian@94
    91
      Description=:new.Description
adrian@94
    92
    WHERE S_Resource_ID=:new.S_Resource_ID;
adrian@94
    93
  END IF;
antonio@735
    94
END S_RESOURCE_TRG
gorkaion@239
    95
]]></body>
adrian@94
    96
    </trigger>
adrian@94
    97
  </database>