src-db/database/model/functions/AD_TRANSLATE_ID.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Wed, 03 Sep 2008 17:55:37 +0000
changeset 1605 8a0fe0193bef
parent 756 ae11e4610537
child 6701 690d2af86089
permissions -rw-r--r--
Merge r2.5x intro trunk
carlos@0
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="FUNCTION AD_TRANSLATE_ID">
juanpablo@1605
     3
    <function name="AD_TRANSLATE_ID" type="VARCHAR">
juanpablo@1605
     4
      <parameter name="p_id" type="VARCHAR" mode="in">
antonio@735
     5
        <default/>
antonio@735
     6
      </parameter>
antonio@735
     7
      <parameter name="p_offset" type="NUMERIC" mode="in">
antonio@735
     8
        <default/>
antonio@735
     9
      </parameter>
antonio@735
    10
      <parameter name="p_tablename" type="VARCHAR" mode="in">
antonio@735
    11
        <default/>
antonio@735
    12
      </parameter>
antonio@735
    13
      <parameter name="p_columnname" type="VARCHAR" mode="in">
antonio@735
    14
        <default/>
antonio@735
    15
      </parameter>
juanpablo@1605
    16
      <parameter name="p_clientid" type="VARCHAR" mode="in">
antonio@735
    17
        <default/>
antonio@735
    18
      </parameter>
gorkaion@239
    19
      <body><![CDATA[/*************************************************************************
carlos@0
    20
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
    21
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
    22
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    23
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    24
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    25
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    26
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    27
* License for the specific  language  governing  rights  and  limitations
carlos@0
    28
* under the License.
carlos@0
    29
* The Original Code is Openbravo ERP.
carlos@0
    30
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    31
* All portions are Copyright (C) 2001-2006 Openbravo SL
carlos@0
    32
* All Rights Reserved.
carlos@0
    33
* Contributor(s):  ______________________________________.
carlos@0
    34
************************************************************************/
carlos@0
    35
/*************************************************************************
carlos@0
    36
* Title: Return the value of the ID selected in the new client
carlos@0
    37
************************************************************************/
juanpablo@1605
    38
  v_ID VARCHAR2(32);
carlos@0
    39
BEGIN
carlos@0
    40
  IF(p_ID IS NOT NULL) THEN
carlos@0
    41
    EXECUTE IMMEDIATE 'SELECT MAX('||p_columnName||') FROM '||p_tableName||' WHERE '||p_columnName||'='||p_ID||' AND AD_CLIENT_ID  ='||p_clientID INTO v_ID;
carlos@0
    42
    IF(v_ID IS NULL) THEN
carlos@0
    43
      v_ID:=p_ID;
carlos@0
    44
    ELSE
carlos@0
    45
      v_ID:=v_ID + p_offset;
carlos@0
    46
    END IF;
carlos@0
    47
  END IF;
carlos@0
    48
  RETURN v_ID;
antonio@735
    49
END AD_TRANSLATE_ID
gorkaion@239
    50
]]></body>
adrian@94
    51
    </function>
adrian@94
    52
  </database>