- All Superinterfaces:
QueryPart
,Serializable
,Statement
If your RDBMS supports procedural code, local variables can be used in
procedural Block
statements. In most RDBMS, such variables need to be
declared first prior to using them.
Example:
// Assuming import static org.jooq.impl.DSL.*;
Variable<Integer> i = var("i", SQLDataType.INTEGER);
Variable<Integer> j = var("j", SQLDataType.INTEGER);
using(configuration)
.begin(
declare(i),
declare(j).set(1),
i.set(j)
)
.execute();
Just like in T-SQL (SQLDialect.SQLSERVER
), local variables can be
declared anywhere within a Block
. If your RDBMS requires variables to
be declared in a separate DECLARE
clause of the block such as in
PL/SQL (SQLDialect.ORACLE
) and PL/pgSQL
(SQLDialect.POSTGRES
), then jOOQ will generate additional blocks and
necessary DECLARE
clauses to reflect the intended scoping of the
jOOQ code. In order to get predictable results, however, it is recommended to
explicitly declare variables at the beginning of a block.
Instances can be created using DSL.declare(Variable)
and overloads.
- Author:
- Lukas Eder
-
Method Details
-
set
@NotNull @Support({AURORA_POSTGRES,BIGQUERY,DB2,EXASOL,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(T value)Initialise this declaration. -
set
@NotNull @Support({AURORA_POSTGRES,BIGQUERY,DB2,EXASOL,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(Field<T> value)Initialise this declaration. -
setNull
@NotNull @Support({AURORA_POSTGRES,BIGQUERY,DB2,EXASOL,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement setNull()Initialise this declaration withnull
.This method is convenience for calling
set(Object)
, without the necessity of casting the Javanull
literal to(T)
. -
set
@NotNull @Support({AURORA_POSTGRES,BIGQUERY,FIREBIRD,H2,HANA,INFORMIX,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(Select<? extends Record1<T>> value)Initialise this declaration.
-