Layer7 API Management

  • 1.  the jdbc query assertion can be dynamic?

    Posted Jun 24, 2015 12:06 AM

    I defined a JDBC query assertion but works ok if the query is static. There is a way to became the query dynamic. using context variables or something else?



  • 2.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 24, 2015 04:17 AM

    Yes you can use context variable as part of the assertion. You will have to select 'Convert variables to String' as part of SQL query window and specify the context variable as part of the sql query window.

    E.g. select empno, firstname from employee where acitve = ${xyzparam}

    More information on the same is available as part of Help document.




  • 3.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 24, 2015 07:48 PM

    Thanks for your response, but if I put 

     

     

    select c1,c2 from t1  where c1='user1'

     

     

    You get the result from the query

     

    but if I create the context variable v1

     

     

    and put as

     

     

    I get error

     



  • 4.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 25, 2015 02:42 AM

    Try without single quotes around the context variable .

     

    Just - select c1,c2 from t1 where c1 = ${v1}



  • 5.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 25, 2015 02:50 PM

    I tried but the query fails also because is a string and sql requires single quotes for string values



  • 6.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 25, 2015 04:06 PM

    You should try without quotes because the parser will add quotes around variables automatically.



  • 7.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 26, 2015 07:23 AM

    I tried and received his message



  • 8.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 26, 2015 11:09 AM

    A couple things:

    1. I think you got the sql wrong. Should read select c1, c2 from t1 where c1=${v1}

    2. The test button in this dialog will not work when the query contains variables because this variable only exists at runtime. You should make sure the following query tests ok in your GUI [select c1, c2 from t1 where c1='user1']. Then set it back to [select c1, c2 from t1 where c1=${v1}], then test it by calling the service at /ws1



  • 9.  Re: the jdbc query assertion can be dynamic?

    Broadcom Employee
    Posted Aug 19, 2015 09:15 PM

    The correct answer is "Sort of". The JDBC Query assertion builds a prepared statement where context variables get plugged in. That is why you don't need quotes, and that is about as dynamic as we can get. You can NOT build the query as a context variable (e.g. you can't build up WHERE clauses) and you can't pass Sort By parameters, etc. You can only have it use the context variable in statically defined WHERE clauses. Hence Francois' comment.



  • 10.  Re: the jdbc query assertion can be dynamic?

    Posted Jun 30, 2017 11:59 AM

    Hi all,

     

    Is this still possible with the latest version of the probe?