In order to be able to reuse methods in the Jdbc Context as well as others, there must be a way to encapsulate the effects of these contexts.
An actual RETURNING
clause is supported in the SQL dialect of the specified database e.g.
An actual RETURNING
clause is supported in the SQL dialect of the specified database e.g. Postgres.
this typically means that columns returned from Insert/Update/etc... clauses can have other database
operations done on them such as arithmetic RETURNING id + 1
, UDFs RETURNING udf(id)
or others.
In JDBC, the following is done:
connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS))
.
Returning multiple columns from Insert/Update/etc...
Returning multiple columns from Insert/Update/etc... clauses is supported. This generally means that
columns besides auto-incrementing ones can be returned. This is supported by Oracle.
In JDBC, the following is done:
connection.prepareStatement(sql, Array("column1, column2, ..."))
.
Data cannot be returned Insert/Update/etc...
Data cannot be returned Insert/Update/etc... clauses in the target database.
Returning a single field from Insert/Update/etc...
Returning a single field from Insert/Update/etc... clauses is supported. This is the most common
databases e.g. MySQL, Sqlite, and H2 (although as of h2database/h2database#1972 this may change. See #1496
regarding this. Typically this needs to be setup in the JDBC connection.prepareStatement(sql, Array("returnColumn"))
.
In order to be able to reuse methods in the Jdbc Context as well as others, there must be a way to encapsulate the effects of these contexts. This simple interface provides them in a fairly generic manner.