6 Replies Latest reply: Nov 18, 2014 7:08 PM by PAUL YEO RSS

    SQL map error code not working

    PAUL YEO

      Hi All

       

      I have a SQL script below working fine :-

       

      Pick(Match(kode_reject, 5, 39), 'reject human error', 'reject machine error') AS DESC_REJECT;

       

      Due to too many error code , i decide to change to mapping :-

       

      ApplyMap('SegmentMap', subfield(kode_reject,' ',1), 'Other') AS DESC_REJECT;

       

      SegmentMap:

      MAPPING LOAD * INLINE [

      Original, New

      5,Human error

      39,Machine error

      A2,Business Partner

      ];

       

      when i reload script , it does not show any error code , but the DESC_REJECT field all value display null or missing value "-"

       

      any advise where go wrong on below line :-

       

      ApplyMap('SegmentMap', subfield(kode_reject,' ',1), 'Other') AS DESC_REJECT;

        • Re: SQL map error code not working
          PAUL YEO

          Hi All

           

          Any one can help on this ?

           

          Paul

          • Re: SQL map error code not working
            Massimo Grossi

            From Qlik online help

             

            The ApplyMap function is used for mapping any expression to a previously loaded mapping table. The syntax is:

            applymap('mapname', expr [ , defaultexpr ] )

            where:

            mapname is the name of a mapping table that has previously been created through the mapping load or the mapping select statement (see Mapping). Its name must be enclosed by single, straight Quotation Marks in Scripting.

            expr is the expression, the result of which should be mapped.

            defaultexpr is an optional expression which will be used as a default mapping value if the mapping table does not contain a matching value for expr. If no default value is given, the value of expr will be returned as is.

            Examples:

            // Assume the following mapping table:

            map1:

            mapping load * inline [

            x, y

            1, one

            2, two

            3, three ] ;

             

            ApplyMap ('map1', 2 ) returns ' two'

            ApplyMap ('map1', 4 ) returns 4

            ApplyMap ('map1', 5, 'xxx') returns 'xxx'

            ApplyMap ('map1', 1, 'xxx') returns 'one'

            ApplyMap ('map1', 5, null( ) ) returns NULL

            ApplyMap ('map1', 3, null( ) ) returns 'three'

             

            The MapSubstring function is used to map parts of any expression to a previously loaded mapping table. The mapping is case sensitive and non-iterative and substrings are mapped from left to right. The syntax is:

            mapsubstring('mapname', expr)

            This function can be used for mapping parts of any expression on a previously loaded mapping table. The mapping is case sensitive and non-recursive. The substrings are mapped from the left to the right. Mapname is the name of a mapping table previously read by a mapping load or a mapping select statement (see Mapping). The name must be enclosed by single straight quotation marks. Expr is the expression whose result should be mapped by substrings.

            Examples:

            // Assume the following mapping table:

            map1:

            mapping load * inline [

            x, y

            1, <one>

            aa, XYZ

            x, b ] ;

             

            MapSubstring ('map1', 'A123') returns 'A<one>23'

            MapSubstring ('map1', 'baaar') returns 'bXYZar'

            MapSubstring ('map1', 'xaa1') returns 'bXYZ<one>'

              • Re: SQL map error code not working
                PAUL YEO

                Hi Massimo

                 

                Thank you for the documentation , in fact i have use this mapping command for my project before , but this is the first time i try read raw data from SQL , and i am not sure why SQL not allow create mapping table before load raw data from SQL , as i place the mapping table before loading SQL data i get error , any way to avoid it ?

                 

                Paul