-
- All Superinterfaces:
QueryPart
,Serializable
,Statement
@Pro public interface Declaration<T> extends Statement
A local variable declaration.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 aBlock
. If your RDBMS requires variables to be declared in a separateDECLARE
clause of the block such as in PL/SQL (SQLDialect.ORACLE
) and PL/pgSQL (SQLDialect.POSTGRES
), then jOOQ will generate additional blocks and necessaryDECLARE
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull Statement
set(Field<T> value)
Initialise this declaration.@NotNull Statement
set(Select<? extends Record1<T>> value)
Initialise this declaration.@NotNull Statement
set(T value)
Initialise this declaration.@NotNull Statement
setNull()
Initialise this declaration withnull
.
-
-
-
Method Detail
-
set
@NotNull @Support({AURORA_POSTGRES,DB2,FIREBIRD,H2,HANA,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(T value)
Initialise this declaration.
-
set
@NotNull @Support({AURORA_POSTGRES,DB2,FIREBIRD,H2,HANA,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(Field<T> value)
Initialise this declaration.
-
set
@NotNull @Support({AURORA_POSTGRES,H2,MARIADB,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER}) @NotNull Statement set(Select<? extends Record1<T>> value)
Initialise this declaration.
-
setNull
@NotNull @Support({AURORA_POSTGRES,H2,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)
.
-
-