Query inputs using 'Set Macros'

spoortispoorti MemberPosts:24Contributor II
edited September 2019 inHelp
I have a query which requires more than one input parameters. As an example
Select count(*) from TestTable where date > '2012/10/05' and date < '2012/10/10'
I would like to pass the date parameter as variable . So my query will look like
Select count(*) from TestTable where date > ? and date < ?
How do I pass 2 variables to the 'Read Database Operator' ? I tried usibg 'Set Macros' and defined 'dt1' and 'dt2' and used them in 'Read Database' with 'prepare statement' and adding VARCHAR {%dt1} and {%dt2} to the Edit Enumeration.

I get the error
ERROR: invalid input syntax for type date: "dt1"

Is there different way to pass more than one variables to sql statement ? It works fine if I have one variable . E.g
Select Count(*) from TestTable where date = ?
And define input variable with 'Set Macro'.
Tagged:

Answers

  • spoortispoorti MemberPosts:24Contributor II
    Any help on this ? Is there any other way to achieve this ?
    Thanks.
  • SkirzynskiSkirzynski MemberPosts:164Maven
    The correct syntax for a macro is %{dt1} and not {%dt1}. Please check your syntax in the enumeration. If this does not help and was just a typo in your posting: Build a minimal example and post it (do not forget the code-tags) so i can take a look.

    Marcin
  • spoortispoorti MemberPosts:24Contributor II
    Here is XML for the process I have created






    <宏/ >

    <运营商激活d="true" class="process" compatibility="5.2.008" expanded="true" name="Process">

    <运营商激活d="true" class="read_database" compatibility="5.2.008" expanded="true" height="60" name="Read Database" width="90" x="179" y="30">









    <运营商激活d="true" class="set_macros" compatibility="5.2.008" expanded="true" height="76" name="Set Macros" width="90" x="45" y="120">













    kypexin
Sign InorRegisterto comment.