src-db/database/model/functions/C_LOCATION_DESCRIPTION.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 C_LOCATION_DESCRIPTION">
adrian@94
     3
    <function name="C_LOCATION_DESCRIPTION" type="NVARCHAR">
juanpablo@1605
     4
      <parameter name="p_c_location_id" type="VARCHAR" mode="in">
antonio@735
     5
        <default/>
antonio@735
     6
      </parameter>
gorkaion@239
     7
      <body><![CDATA[/*************************************************************************
carlos@0
     8
* The contents of this file are subject to the Openbravo  Public  License
carlos@0
     9
* Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
    10
* Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
    11
* file except in compliance with the License. You  may  obtain  a copy of
carlos@0
    12
* the License at http://www.openbravo.com/legal/license.html
carlos@0
    13
* Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
    14
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    15
* License for the specific  language  governing  rights  and  limitations
carlos@0
    16
* under the License.
carlos@0
    17
* The Original Code is Openbravo ERP.
carlos@0
    18
* The Initial Developer of the Original Code is Openbravo SL
carlos@0
    19
* All portions are Copyright (C) 2001-2006 Openbravo SL
carlos@0
    20
* All Rights Reserved.
carlos@0
    21
* Contributor(s):  ______________________________________.
carlos@0
    22
************************************************************************/
carlos@0
    23
/*************************************************************************
carlos@0
    24
* Title:   Return the description of the location
carlos@0
    25
* Description:
carlos@0
    26
*
carlos@0
    27
************************************************************************/
carlos@0
    28
  v_description NVARCHAR2(4000) ;
carlos@0
    29
BEGIN
carlos@0
    30
  SELECT COALESCE(TO_CHAR(L.ADDRESS1), '') ||(
carlos@0
    31
    CASE
carlos@0
    32
      WHEN(L.ADDRESS2) IS NULL
carlos@0
    33
      THEN ''
carlos@0
    34
      ELSE(CHR(10) ||TO_CHAR(L.ADDRESS2))
carlos@0
    35
    END
carlos@0
    36
    ) || (
carlos@0
    37
    CASE
carlos@0
    38
      WHEN(L.POSTAL||L.CITY||R.NAME) IS NULL
carlos@0
    39
      THEN ''
carlos@0
    40
      ELSE CHR(10) ||L.POSTAL ||(
carlos@0
    41
      CASE
carlos@0
    42
        WHEN(L.POSTAL) IS NULL
carlos@0
    43
        THEN ''
carlos@0
    44
        ELSE ' - '||TO_CHAR(L.CITY)
carlos@0
    45
      END
carlos@0
    46
      ) || (
carlos@0
    47
      CASE
carlos@0
    48
        WHEN(R.NAME) IS NULL
carlos@0
    49
        THEN ''
carlos@0
    50
        ELSE ' ('||TO_CHAR(R.NAME) || ')'
carlos@0
    51
      END
carlos@0
    52
      )
carlos@0
    53
    END
carlos@0
    54
    )
carlos@0
    55
  INTO v_description
carlos@0
    56
  FROM C_LOCATION L
carlos@0
    57
  LEFT JOIN C_REGION R
carlos@0
    58
    ON L.C_REGION_ID=R.C_REGION_ID
carlos@0
    59
  WHERE L.C_LOCATION_ID=p_C_Location_ID;
carlos@0
    60
  RETURN v_description;
antonio@735
    61
END C_LOCATION_DESCRIPTION
gorkaion@239
    62
]]></body>
adrian@94
    63
    </function>
adrian@94
    64
  </database>