Thanks Alex.
I am not sure this answers my question.
My question: How do I dynamically set the arguments in setArgs of
SqlFieldsQuery.
For example:
sql1 = "select a,b,c from table x where age >?"
sql2 = "select a,b,c from table x where age >? and salary < ?"
sql3 = "select a,b,c,d from table x where dept = ? and age > ? and name =
? and city = ?"
As you see each sql has a different number of arguments. I want to be able
to pass an array/collection to setArgs, and have it instantiate all the
arguments in the SQL to the values that I am passing to setArgs.
For example,
SqlFieldsQuery(sql3).setArgs("dev",30,"john", "NY"');
SqlFieldsQuery(sql1).setArgs(30);
I understand that setArgs has the following format.
public SqlFieldsQuery
<https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/cache/query/SqlFieldsQuery.html>
setArgs(Object
<https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true>...
args)
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/cache/query/SqlFieldsQuery.html
thanks
On Mon, Jan 11, 2021 at 2:14 PM akorensh <[email protected]> wrote:
> Hi,
> Take a look at this example:
>
> https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/sql/SqlQueriesExample.java
>
> Use this as a template:
>
> String sql = "select * from Person where salary > ? and salary <=
> ?";
>
> // Execute queries for salary ranges.
> print("People with salaries between 0 and 1000 (queried with SQL
> query): ",
> cache.query(new SqlFieldsQuery(sql).setArgs(0,
> 1000)).getAll());
>
> print("People with salaries between 1000 and 2000 (queried with SQL
> query): ",
> cache.query(new SqlFieldsQuery(sql).setArgs(1000,
> 2000)).getAll());
>
> Thanks, Alex
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>