Skip to main content

Values

Definition

The values methods allows you to add the VALUES clause to the query.

Available methods

1. values(KValues kValues)

  • kValues: are all the values that will be supplied to the VALUES clause.
    Among the possible values are: Number, String, LocalDate, LocalDateTime, UUID, KTableColumn, KColumn KRaw.

Method hierarchy

The values method can be used right after the following methods or objects:

and the subsequent methods that can be called are:

Example: Fixed records

Java code:

final KValues user = values()
.append("contacto@myzlab.com", crypt("my-password"))
.append("no-pass@yopmail.com", null);

k
.insertInto(APP_USER)
.columns(
APP_USER.EMAIL,
APP_USER.PASSWORD
)
.values(user)
.execute();

SQL generated:

INSERT INTO app_user (email, password)
VALUES
(?1, CRYPT(?2, GEN_SALT(?3))),
(?4, NULL)

Parameters:

Example: Variable records

Java code:

final List<Language> languages = ...;

final KValues values = values().append(languages,
(KValuesFunction<Language>) (final Language l) -> new ArrayList() {{
add(l.getName());
add(l.getFile());
}}
);

k
.insertInto(LANGUAGE)
.columns(
LANGUAGE.NAME,
LANGUAGE.FILE
)
.values(values)
.execute();

SQL generated:

INSERT INTO language (name, file)
VALUES (?1, ?2), (?3, ?4)

Parameters:

  • ?1: "Language 1"
  • ?2: "File 1"
  • ?3: "Language 2"
  • ?4: "File 2"