0 | module Oracle.Types.Query
 1 |
 2 | import Oracle.Types.BindParameter
 3 | import Oracle.Types.QueryColumn
 4 |
 5 | ||| Represents a SQL query executed by the Oracle client.
 6 | |||
 7 | ||| `columns` specifies the expressions in the SELECT projection.
 8 | |||
 9 | ||| Each expression may either be selected normally with `Column`, or serialized as JSON text with `JSONColumn`.
10 | |||
11 | ||| `querybody` contains the FROM clause and any additional SQL clauses required to construct the query, such as WHERE, ORDER BY, GROUP BY, or JOIN clauses.
12 | |||
13 | ||| `binds` contains the bind parameters used by the SQL statement.
14 | |||
15 | ||| For example:
16 | |||
17 | |||   MkQuery
18 | |||     [ Column "id"
19 | |||     , Column "name"
20 | |||     , JSONColumn "profile"
21 | |||     ]
22 | |||     "people WHERE active = :active ORDER BY id"
23 | |||     [MkBindParameter ":active" (OracleBool True)]
24 | |||
25 | ||| Renders to SQL equivalent to:
26 | |||
27 | |||   SELECT id, name, JSON_SERIALIZE(profile RETURNING CLOB)
28 | |||   FROM people
29 | |||   WHERE active = :active
30 | |||   ORDER BY id
31 | |||
32 | public export
33 | record Query where
34 |   constructor MkQuery
35 |   columns   : List QueryColumn
36 |   querybody : String
37 |   binds     : List BindParameter
38 |