1 package com.github.davidmoten.rx.jdbc;
2
3 import java.util.List;
4
5 import rx.Observable;
6 import rx.Scheduler;
7
8 /**
9 * A database DML query, either update/insert or select.
10 */
11 public interface Query {
12
13 /**
14 * Returns the sql statement for this query following JDBC format (? for
15 * parameters for instance).
16 *
17 * @return jdbc sql
18 */
19 String sql();
20
21 /**
22 * Returns the list of names corresponding positionally to the ? characters in
23 * the sql. If names were not used then returns an empty list.
24 *
25 * @return ist of names corresponding positionally to the ? characters in
26 * the sql
27 */
28 List<String> names();
29
30 /**
31 * Returns the parameters for the query in order of appearance as ? markers
32 * in the sql. May emit more than the number of parameters in one run of the
33 * query in which case the query would be run multiple times.
34 *
35 * @return
36 */
37 Observable<Parameter> parameters();
38
39 /**
40 * Returns the Observables that have to complete before this query is
41 * started.
42 *
43 * @return
44 */
45 Observable<?> depends();
46
47 /**
48 * Returns the query context including {@link ConnectionProvider} and
49 * {@link Scheduler}.
50 *
51 * @return
52 */
53 QueryContext context();
54
55 }