cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an escape character to handle Quotes in a string to apply filter in Calculation Views?

srujan_gannamaneni
Participant
0 Kudos

Hi Everyone

I am trying to apply a static filter ( Field1 = 'INT'L REPORT' ) in HANA Calculation view.
Is there an escape character to handle single quote present in String Value?

We might achieve this by changing the Execution engine in Filter expression from Column Engine to SQL Engine.
But, I would like know if we can achieve the same without changing the engine.

I tried writing the expression as mentioned below but it returned an error.

Field1 = 'INT''L REPORT'

Please help me if there is a solution to achieve this without changing the Execution engine.

Thanks and Regards

Srujan Gannamaneni

srujan_gannamaneni
Participant
0 Kudos

Hi Utsav,

I think you must be using apply_filter in a procedure (correct me if not)

  1. If you are trying in Procedure, try using it as mentioned below

    call <procedure_name> (<filter_param> => 'Field1 = ''INTL''''REPORT''')
    That should work. We need to escape all the internal single quotes which are being used to generate filter expression using APPLY_FILTER
  2. If you are trying in Scripted view,

    You must be facing issue as it applies both \ as well as ' while creating the filter expression
    say,

    If you give NAME = 'SRUJAN', It will create filter expression as NAME = \''SRUJAN\''

    I made a small adjustment in my script to handle this '\' .
  1. /********* Begin Procedure Script************/
    BEGIN

    declare INPU nvarchar(100);
    INPU := trim(replace(:ip,'\',''));
    var_out1 = SELECT NAME FROM "TEST_TAB";
    var_out = APPLY_FILTER(:var_out1,:INPU);
    END/********* End Procedure Script ************/


  1. And while applying the parameter, I simply gave NAME = 'INTL''REPORT.

It worked as we are handing '\' in our code.

Please try it out and let me know if you face any issue. I wish I could attach some images but I couldn't as it is not letting me submit when I add one.

Best Regards
Srujan Gannamaneni

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor

In a column engine filter expression a good old backslash does the job (although the syntax validation marks it as wrong in my case, but activation and execution works).

Field1 = 'INT\'L REPORT'

Regards,
Florian

srujan_gannamaneni
Participant
0 Kudos

Hey Florian,

Sorry for the late reply.
Its working.
Thank you 🙂

Best Regards

Srujan Gannamaneni

Answers (0)