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
<?xml version="1.0"?>
  <database name="FUNCTION C_ELEMENTVALUE_COPY">
    <function name="C_ELEMENTVALUE_COPY" type="NULL">
      <parameter name="p_source_element_id" type="VARCHAR" mode="in">
        <default/>
      </parameter>
      <parameter name="p_target_element_id" type="VARCHAR" mode="in">
        <default/>
      </parameter>
      <body><![CDATA[/*************************************************************************
  * The contents of this file are subject to the Compiere Public
  * License 1.1 ("License"); You may not use this file except in
  * compliance with the License. You may obtain a copy of the License in
  * the legal folder of your Openbravo installation.
  * Software distributed under the License is distributed on an
  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  * implied. See the License for the specific language governing rights
  * and limitations under the License.
  * The Original Code is  Compiere  ERP &  Business Solution
  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
  * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
  * All Rights Reserved.
  * Contributor(s): Openbravo SL
  * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
  *
  * Specifically, this derivative work is based upon the following Compiere
  * file and version.
  *************************************************************************
  *  Copies CoA
  * All element values of p_Source_Element_ID to p_Target_Element_ID
  */
  TYPE RECORD IS REF CURSOR;
    Cur_ElementValue RECORD;
    v_xAD_Client_ID VARCHAR2(32);
    v_xAD_Org_ID VARCHAR2(32);
    v_xUpdated DATE;
    v_xUpdatedBy NUMBER;
    v_NextNo VARCHAR2(32);
  BEGIN
    --  Get target base info
    SELECT AD_Client_ID,
      AD_Org_ID,
      Updated,
      UpdatedBy
    INTO v_xAD_Client_ID,
      v_xAD_Org_ID,
      v_xUpdated,
      v_xUpdatedBy
    FROM C_Element
    WHERE C_Element_ID=p_Target_Element_ID;
    FOR Cur_ElementValue IN
      (SELECT *
      FROM C_ElementValue
      WHERE C_Element_ID=p_Source_Element_ID
        AND IsActive='Y'
      )
    LOOP
      AD_Sequence_Next('C_ElementValue', p_Target_Element_ID, v_NextNo) ;
      INSERT
      INTO C_ElementValue
        (
          C_ElementValue_ID, C_Element_ID, AD_Client_ID, AD_Org_ID,
          IsActive, Created, CreatedBy, Updated,
          UpdatedBy, Value, Name, Description,
          AccountType, AccountSign, IsDocControlled, IsSummary,
          ValidFrom, ValidTo, PostActual, PostBudget,
          PostEncumbrance, PostStatistical, IsForeignCurrency, C_Currency_ID
        )
        VALUES
        (
          v_NextNo, p_Target_Element_ID, v_xAD_Client_ID, v_xAD_Org_ID,
           'Y', v_xUpdated, v_xUpdatedBy, v_xUpdated,
          v_xUpdatedBy, Cur_ElementValue.Value, Cur_ElementValue.Name, Cur_ElementValue.Description,
          Cur_ElementValue.AccountType, Cur_ElementValue.AccountSign, Cur_ElementValue.IsDocControlled, Cur_ElementValue.IsSummary,
          Cur_ElementValue.ValidFrom, Cur_ElementValue.ValidTo, Cur_ElementValue.PostActual, Cur_ElementValue.PostBudget,
          Cur_ElementValue.PostEncumbrance, Cur_ElementValue.PostStatistical, Cur_ElementValue.IsForeignCurrency, Cur_ElementValue.C_Currency_ID
        )
        ;
    END LOOP;
    -- Commented by cromero 19102006 COMMIT;
END C_ELEMENTVALUE_COPY
]]></body>
    </function>
  </database>