Layer7 API Management

 View Only
  • 1.  How can I convert a string multivalued variable to an int multivalued?

    Posted Apr 29, 2016 10:34 AM

    Hi there

     

    I have a jdbc query with several IN clauses, all of them need string parameters except one, which needs integers. As the jdbc assertion needs multivalued variables in this case, I just split the comma separated input data  with a split assertion, which produces what I want, for strings. But how can I then convert a string multivalued variable to an int one? Or how can I split a comma separated list of numbers and get a int multivalued variable?

     

    Thanks

    John



  • 2.  Re: How can I convert a string multivalued variable to an int multivalued?

    Broadcom Employee
    Posted May 04, 2016 10:38 PM

    Hello John,

    If the option "Converting Variables into Strings" is not checked, the jdbc query should return the raw data.

    Then you should be able to,

    - Run Assertions for each time of ${<jdbcquery prefix>.<integer column>} as ${i.current}

    \__ Manipulate Multivalued Variable <your multi int var> append variable i.current

     

    to get the int multivalued variable.

     

    NOTE that long type is not supported.

     

    Regards,

    Mark



  • 3.  Re: How can I convert a string multivalued variable to an int multivalued?

    Posted May 06, 2016 04:36 AM

    Hello Mark

    Thank you for your answer.

    Actually what I'm trying to convert is not the jdbc results but the parameters for the query prepared statement.

    Let say I have a query like this one:

    select *

    from employees

    where emp_number in (${par_emp_number})

     

    The ${par_emp_number} parameter must be an interger list of employee numbers because the type of the emp_number attribute of the employe table is number. In the policy I get the employee numbers in a comma separated string like "100,200,300,400,500" which I split with the split assertion. In this way I get a string multivalued variable. I tried then to convert it in a int multivalued one like you suggest, but unfortunately the conversion string to int fails.

     

    Regards,

    John



  • 4.  Re: How can I convert a string multivalued variable to an int multivalued?
    Best Answer

    Broadcom Employee
    Posted May 08, 2016 10:01 PM

    Hello John,

    The query statement is a string. You don't need interge to build query statement.

    For your case, string "100,200,300,400,500" is all you need.

    ie. put 100,200,300,400,500 into ${par_emp_number} as string

     

    Regards,

    Mark