12 Replies Latest reply on Apr 25, 2014 2:59 AM by satyajit das

    Switchyard reference - How to change SQL query at runtime?

    Krzysztof Stelmach Newbie



      I look for example with switchard's SQL reference where I can change SQL query dynamically (from code (Java Bean or Camel)) depends on request data.

      In my project I need to find persons with given firstname and/or lastname and/or age.

      The full SQL query is:

      SELECT * FROM persons WHERE firstname = # AND lastname = # AND age >= # AND age <= #

      The input params aren't required. Therefore for example if firstname is empty than SQL query should be:

      SELECT * FROM persons WHERE lastname = # AND age >= # AND age <= #


      I don't want create many references with separate SQL query. The best solution is one reference where I can change query at runtime.


      How to solve above problem? If possible.