1 2 Previous Next 18 Replies Latest reply on Feb 15, 2018 3:32 PM by Nicole Maalouf

    Query Language - Special Characters

    Nicole Maalouf

      Hello,

       

      Is there special way to escape characters in ADDM generic query language? I have a name set with "-" in the middle of it. For example:

       

       

      The name may appear as "Query Language - Special Characters"

       

      But, I cannot return anything when running the following queries:

       

      search BusinessApplicationInstance where name = ''Query Language - Special Characters''

       

      search BusinessApplicationInstance where name matches "Query Language -"

       

      search BusinessApplicationInstance where name = ''Query Language -''

        • 1. Re: Query Language - Special Characters
          Andrew Waters

          I assume you mean from the UI? there is nothing special with "-". Are you sure that you did not end up with a different character than you think. Unicode helpfully has lots of hyphen characters.

          1 of 1 people found this helpful
          • 2. Re: Query Language - Special Characters
            Nicole Maalouf

            Yes, querying from the generic query function in the UI.

             

            I copied directly from the "Name" attribute on the BAI in the UI and pasted in to the query, I assume this would give me the same hyphen.

             

            I also tried to rewrite the code setting the attribute to use "(" in place of "-", and could not query by that character either. I can query any text before or after, but not the entire "Query Language - Special Characters"

            • 3. Re: Query Language - Special Characters
              Andrew Waters

              I trust you spelt BusinessApplicationInstance correctly in the query.

               

              If you look in tw_svc_model.log does it show the correct query?

              1 of 1 people found this helpful
              • 4. Re: Query Language - Special Characters
                Bob Anderson

                Check your quoting characters

                 

                I copied from your post, and the 2 searches that look for equality 2 single quotes before and after the string.

                 

                The search using 'matches' shows 1 double quote before and after the string.The courier font facse shows that very clearly:

                 

                search BusinessApplicationInstance where name = ''Query Language - Special Characters''

                search BusinessApplicationInstance where name matches "Query Language -"

                search BusinessApplicationInstance where name = ''Query Language -''

                 

                I tried to do a similar search, just using the hyphen characters, but in SoftwareInstance, like this:

                 

                search SoftwareInstance where name matches '-'

                 

                yields results in 11.1, and 11.2 but

                 

                search SoftwareInstance where name matches ''-''

                 

                yields no results in 11.1

                and Expression Not Supported in 11.2+

                 

                Your first query may work if you just used 1 single quote for the string

                Your second query should work, unless there are other white space characters in the name that we cannot see.

                Your third query should return nothing, even when fixing the quotes for the string.

                 

                You could also try some more regex specific pattern matching like

                 

                search BusinessApplicationInstance where name matches regex '^(?i)Query\s+Language\s+-'

                 

                HTH


                Bob

                2 of 2 people found this helpful
                • 5. Re: Query Language - Special Characters
                  Nicole Maalouf

                  I had no luck with either of these either, single quotes or regex..

                   

                  search BusinessApplicationInstance where name matches '- Special Characters'

                   

                  returns results

                   

                  however, the entire string still returns nothing 'Query Language - Special Characters'

                  • 6. Re: Query Language - Special Characters
                    Andrew Waters

                    You cannot be matching the actual value. If the first case works then that would imply you need to be looking at the beginning of the value.

                    1 of 1 people found this helpful
                    • 7. Re: Query Language - Special Characters
                      Bob Anderson

                      As Andrew said, if the first case is not working, then there are some other 'white space' characters (more spaces, tabs, new-line, carriage-return, etc) in the actual BAI name.

                       

                      Try searching for the word 'Query' in the BusinessApplicationInstance name, as this removes any attempt to also find 'white space' characters.

                       

                      search BusinessApplicationInstance where name matches regex '(?i)query' show fmt('-->%s<--', name) as 'Formatted Name'

                       

                      This debugging query just adds some 'pinchers' around the name attribute which helps to un-hide some leading or trailing white-space characters.

                       

                      If this brings back expected one of your sought-after BAIs, the problem is more than likely in one of 2 places:  Either the 'copy and paste' of the BusinessApplicationInstance name included some 'white-space' characters that were not matched in the first search queries, or the code where the BusinessApplicationInstance 'name' attribute is generated is including some white-space characters that are not being matched in the first search queries.

                       

                      Just curious, how were the BAIs created? With SAAM, CAM, or your own custom patterns?

                      2 of 2 people found this helpful
                      • 8. Re: Query Language - Special Characters
                        Nicole Maalouf

                        I still do not seem to be able to query correctly using these suggestions. The BAI was created with a custom pattern where I define it as -->

                         

                          bai_name := "%app_name% - %lifecycle%";

                         

                        This value appears correctly on the BAI name in the ADDM UI, but copying exactly from there does not allow me to find it in a query.

                        • 9. Re: Query Language - Special Characters
                          Nicole Maalouf

                          I see no white space before or after while using the debugging query you offered

                          • 10. Re: Query Language - Special Characters
                            Nicole Maalouf

                            These return correctly:

                             

                            search BusinessApplicationInstance where name matches regex '(?i)- Special Characters' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                            search BusinessApplicationInstance where name matches regex '(?i) - Special Characters' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                            As soon as I add text before the "-", returns nothing:

                             

                            search BusinessApplicationInstance where name matches regex '(?i)y - Special Characters' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                             

                             

                            From the beginning, these return correctly:

                             

                            search BusinessApplicationInstance where name matches regex '(?i)Query' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                            search BusinessApplicationInstance where name matches regex '(?i)Query ' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                             

                            As soon as I add "-" after the space, returns nothing:

                             

                            search BusinessApplicationInstance where name matches regex '(?i)Query -' show fmt('-->%s<--', name) as 'Formatted Name'

                             

                             

                             

                            Leads me to believe there has to be an issue with interpreting the dash "-"

                            • 11. Re: Query Language - Special Characters
                              Andrew Waters

                              There is no interpretation of a dash.

                               

                              Have you tried exporting to a CSV file so you can exactly see the name.

                              1 of 1 people found this helpful
                              • 12. Re: Query Language - Special Characters
                                Nicole Maalouf

                                great suggestion! seems there is a line return between "y" and the space before the -

                                 

                                this does not necessarily appear in the CSV, but if I copy from the csv to notepad it pastes as:

                                 

                                Query

                                - Special Characters'

                                 

                                So, can I query to ignore line returns?

                                • 13. Re: Query Language - Special Characters
                                  Nicole Maalouf

                                  or - any idea how this was set in this way?

                                   

                                  Earlier, I tried to set it in my TPL pattern using "Query(Special Characters)" instead, this pastes the same way with a line break

                                  • 14. Re: Query Language - Special Characters
                                    Shane Smith

                                    Sounds like the  %app_name% variable has a \n or \r on the end of it which would be an artifact of how you are getting that value.  It may help to do a

                                    log.debug("App Name: %bai_name%");

                                     

                                    This could account for it if you know there are one or more (space, tab, new line, return, )

                                    search BusinessApplicationInstance where name matches regex '(?i)y\s+- Special Characters' show fmt('-->%s<--', name) as 'Formatted Name'

                                    1 of 1 people found this helpful
                                    1 2 Previous Next