src-db/database/model/functions/C_ELEMENTVALUE_COPY.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 785 8dba91261590
child 3645 a509cd280aa7
permissions -rw-r--r--
Merge r2.5x intro trunk
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION C_ELEMENTVALUE_COPY">
adrian@94
     3
    <function name="C_ELEMENTVALUE_COPY" type="NULL">
juanpablo@1605
     4
      <parameter name="p_source_element_id" type="VARCHAR" mode="in">
antonio@735
     5
        <default/>
antonio@735
     6
      </parameter>
juanpablo@1605
     7
      <parameter name="p_target_element_id" type="VARCHAR" mode="in">
antonio@735
     8
        <default/>
antonio@735
     9
      </parameter>
gorkaion@239
    10
      <body><![CDATA[/*************************************************************************
juanpablo@771
    11
  * The contents of this file are subject to the Compiere Public
juanpablo@771
    12
  * License 1.1 ("License"); You may not use this file except in
juanpablo@771
    13
  * compliance with the License. You may obtain a copy of the License in
juanpablo@771
    14
  * the legal folder of your Openbravo installation.
carlos@0
    15
  * Software distributed under the License is distributed on an
carlos@0
    16
  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
carlos@0
    17
  * implied. See the License for the specific language governing rights
carlos@0
    18
  * and limitations under the License.
juanpablo@778
    19
  * The Original Code is  Compiere  ERP &  Business Solution
juanpablo@771
    20
  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
carlos@0
    21
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
carlos@0
    22
  * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
carlos@0
    23
  * All Rights Reserved.
carlos@0
    24
  * Contributor(s): Openbravo SL
juanpablo@785
    25
  * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
juanpablo@771
    26
  *
juanpablo@771
    27
  * Specifically, this derivative work is based upon the following Compiere
juanpablo@771
    28
  * file and version.
carlos@0
    29
  *************************************************************************
carlos@0
    30
  *  Copies CoA
carlos@0
    31
  * All element values of p_Source_Element_ID to p_Target_Element_ID
carlos@0
    32
  */
carlos@0
    33
  TYPE RECORD IS REF CURSOR;
carlos@0
    34
    Cur_ElementValue RECORD;
juanpablo@1605
    35
    v_xAD_Client_ID VARCHAR2(32);
juanpablo@1605
    36
    v_xAD_Org_ID VARCHAR2(32);
carlos@0
    37
    v_xUpdated DATE;
carlos@0
    38
    v_xUpdatedBy NUMBER;
juanpablo@1605
    39
    v_NextNo VARCHAR2(32);
carlos@0
    40
  BEGIN
carlos@0
    41
    --  Get target base info
carlos@0
    42
    SELECT AD_Client_ID,
carlos@0
    43
      AD_Org_ID,
carlos@0
    44
      Updated,
carlos@0
    45
      UpdatedBy
carlos@0
    46
    INTO v_xAD_Client_ID,
carlos@0
    47
      v_xAD_Org_ID,
carlos@0
    48
      v_xUpdated,
carlos@0
    49
      v_xUpdatedBy
carlos@0
    50
    FROM C_Element
carlos@0
    51
    WHERE C_Element_ID=p_Target_Element_ID;
carlos@0
    52
    FOR Cur_ElementValue IN
carlos@0
    53
      (SELECT *
carlos@0
    54
      FROM C_ElementValue
carlos@0
    55
      WHERE C_Element_ID=p_Source_Element_ID
carlos@0
    56
        AND IsActive='Y'
carlos@0
    57
      )
carlos@0
    58
    LOOP
carlos@0
    59
      AD_Sequence_Next('C_ElementValue', p_Target_Element_ID, v_NextNo) ;
carlos@0
    60
      INSERT
carlos@0
    61
      INTO C_ElementValue
carlos@0
    62
        (
carlos@0
    63
          C_ElementValue_ID, C_Element_ID, AD_Client_ID, AD_Org_ID,
carlos@0
    64
          IsActive, Created, CreatedBy, Updated,
carlos@0
    65
          UpdatedBy, Value, Name, Description,
carlos@0
    66
          AccountType, AccountSign, IsDocControlled, IsSummary,
carlos@0
    67
          ValidFrom, ValidTo, PostActual, PostBudget,
carlos@0
    68
          PostEncumbrance, PostStatistical, IsForeignCurrency, C_Currency_ID
carlos@0
    69
        )
carlos@0
    70
        VALUES
carlos@0
    71
        (
carlos@0
    72
          v_NextNo, p_Target_Element_ID, v_xAD_Client_ID, v_xAD_Org_ID,
carlos@0
    73
           'Y', v_xUpdated, v_xUpdatedBy, v_xUpdated,
carlos@0
    74
          v_xUpdatedBy, Cur_ElementValue.Value, Cur_ElementValue.Name, Cur_ElementValue.Description,
carlos@0
    75
          Cur_ElementValue.AccountType, Cur_ElementValue.AccountSign, Cur_ElementValue.IsDocControlled, Cur_ElementValue.IsSummary,
carlos@0
    76
          Cur_ElementValue.ValidFrom, Cur_ElementValue.ValidTo, Cur_ElementValue.PostActual, Cur_ElementValue.PostBudget,
carlos@0
    77
          Cur_ElementValue.PostEncumbrance, Cur_ElementValue.PostStatistical, Cur_ElementValue.IsForeignCurrency, Cur_ElementValue.C_Currency_ID
carlos@0
    78
        )
carlos@0
    79
        ;
carlos@0
    80
    END LOOP;
carlos@0
    81
    -- Commented by cromero 19102006 COMMIT;
antonio@735
    82
END C_ELEMENTVALUE_COPY
gorkaion@239
    83
]]></body>
adrian@94
    84
    </function>
adrian@94
    85
  </database>