src-db/database/model/functions/FRIE_NAME.xml
changeset 799 fef2c5e2feb7
parent 798 4994e5a604bb
child 800 1ad8094b366f
equal deleted inserted replaced
798:4994e5a604bb 799:fef2c5e2feb7
     1 <?xml version="1.0"?>
       
     2   <database name="FUNCTION FRIE_NAME">
       
     3     <function name="FRIE_NAME" type="VARCHAR">
       
     4       <parameter name="p_name" type="VARCHAR" mode="in">
       
     5         <default/>
       
     6       </parameter>
       
     7       <body><![CDATA[/*************************************************************************
       
     8 * The contents of this file are subject to the Compiere Public
       
     9 * License 1.1 ("License"); You may not use this file except in
       
    10 * compliance with the License. You may obtain a copy of the License in
       
    11 * the legal folder of your Openbravo installation.
       
    12 * Software distributed under the License is distributed on an
       
    13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
       
    14 * implied. See the License for the specific language governing rights
       
    15 * and limitations under the License.
       
    16 * The Original Code is  Compiere  ERP &  Business Solution
       
    17 * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
       
    18 * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke,
       
    19 * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
       
    20 * All Rights Reserved.
       
    21 * Contributor(s): Openbravo SL
       
    22 * Contributions are Copyright (C) 2001-2008 Openbravo, S.L.
       
    23 *
       
    24 * Specifically, this derivative work is based upon the following Compiere
       
    25 * file and version.
       
    26 *************************************************************************
       
    27 * $Id: FRIE_Name.sql,v 1.3 2002/10/21 04:49:45 jjanke Exp $
       
    28 ***
       
    29 * Title: Return "clean" Product Name
       
    30 * Description:
       
    31 ************************************************************************/
       
    32   v_RetValue VARCHAR2(60) ;
       
    33 BEGIN
       
    34   -- Clean double spaces
       
    35   v_RetValue := REPLACE(p_Name, '  ', ' ') ;
       
    36   v_RetValue := REPLACE(v_RetValue, '  ', ' ') ;
       
    37   v_RetValue := REPLACE(v_RetValue, '  ', ' ') ;
       
    38   -- Isolate R
       
    39   v_RetValue := REPLACE(v_RetValue, '0R1', '0 R 1') ;
       
    40   v_RetValue := REPLACE(v_RetValue, '0R 1', '0 R 1') ;
       
    41   v_RetValue := REPLACE(v_RetValue, '0 R1', '0 R 1') ;
       
    42   v_RetValue := REPLACE(v_RetValue, '5R1', '5 R 1') ;
       
    43   v_RetValue := REPLACE(v_RetValue, '5R 1', '5 R 1') ;
       
    44   v_RetValue := REPLACE(v_RetValue, '5 R1', '5 R 1') ;
       
    45   v_RetValue := REPLACE(v_RetValue, '0R2', '0 R 2') ;
       
    46   v_RetValue := REPLACE(v_RetValue, '0R 2', '0 R 2') ;
       
    47   v_RetValue := REPLACE(v_RetValue, '0 R2', '0 R 2') ;
       
    48   v_RetValue := REPLACE(v_RetValue, '5R2', '5 R 2') ;
       
    49   v_RetValue := REPLACE(v_RetValue, '5R 2', '5 R 2') ;
       
    50   v_RetValue := REPLACE(v_RetValue, '5 R2', '5 R 2') ;
       
    51   v_RetValue := REPLACE(v_RetValue, '2R2', '2 R 2') ;
       
    52   v_RetValue := REPLACE(v_RetValue, '2R 2', '2 R 2') ;
       
    53   v_RetValue := REPLACE(v_RetValue, '2 R2', '2 R 2') ;
       
    54   v_RetValue := REPLACE(v_RetValue, '0R8', '0 R 8') ;
       
    55   -- Isolate HR
       
    56   v_RetValue := REPLACE(v_RetValue, '0HR1', '0 HR 1') ;
       
    57   -- Isolate VR
       
    58   v_RetValue := REPLACE(v_RetValue, '0VR1', '0 VR 1') ;
       
    59   v_RetValue := REPLACE(v_RetValue, '5VR1', '5 VR 1') ;
       
    60   v_RetValue := REPLACE(v_RetValue, '0VR3', '0 VR 3') ;
       
    61   v_RetValue := REPLACE(v_RetValue, '5VR3', '5 VR 3') ;
       
    62   v_RetValue := REPLACE(v_RetValue, '0VR 1', '0 VR 1') ;
       
    63   v_RetValue := REPLACE(v_RetValue, '5VR 1', '5 VR 1') ;
       
    64   -- Isolate ZR
       
    65   v_RetValue := REPLACE(v_RetValue, '0ZR1', '0 ZR 1') ;
       
    66   v_RetValue := REPLACE(v_RetValue, '5ZR1', '5 ZR 1') ;
       
    67   v_RetValue := REPLACE(v_RetValue, '0ZR 1', '0 ZR 1') ;
       
    68   v_RetValue := REPLACE(v_RetValue, '5ZR 1', '5 ZR 1') ;
       
    69   v_RetValue := REPLACE(v_RetValue, '0 ZR1', '0 ZR 1') ;
       
    70   v_RetValue := REPLACE(v_RetValue, '5 ZR1', '5 ZR 1') ;
       
    71   -- Change "B." => B
       
    72   IF(SUBSTR(v_RetValue, 1, 2) = 'B.') THEN
       
    73     v_RetValue := REPLACE(v_RetValue, 'B.', 'B') ;
       
    74   END IF;
       
    75   -- Remove "D."
       
    76   IF(SUBSTR(v_RetValue, 1, 2) = 'D.') THEN
       
    77     v_RetValue := SUBSTR(v_RetValue, 3) ;
       
    78   END IF;
       
    79   -- Remove "D "
       
    80   IF(SUBSTR(v_RetValue, 1, 2) = 'D ') THEN
       
    81     v_RetValue := SUBSTR(v_RetValue, 3) ;
       
    82   END IF;
       
    83   --
       
    84   RETURN TRIM(v_RetValue) ;
       
    85 END FRIE_NAME
       
    86 ]]></body>
       
    87     </function>
       
    88   </database>