MySQL Shell API  8.0.18
Unified development interface for MySQL Products
Methods | List of all members
TableInsert Class Reference

Handler for Insert operations on Tables. More...

Methods

TableInsert insert ()
 Initializes the record insertion handler. More...
 
TableInsert insert (List columns)
 Initializes the record insertion handler with the received column list. More...
 
TableInsert insert (String col1, String col2,...)
 Initializes the record insertion handler with the received column list. More...
 
TableInsert values (Value value, Value value,...)
 Adds a new row to the insert operation with the given values. More...
 
Result execute ()
 Executes the insert operation. More...
 

Detailed Description

Handler for Insert operations on Tables.

Member Function Documentation

◆ insert() [1/3]

TableInsert insert ( )

Initializes the record insertion handler.

Returns
This TableInsert object.

This function is called automatically when Table.insert() is called.

Method Chaining

After this function invocation, the following functions can be invoked:

  • values(Value value1, Value value2, ...)
  • execute().
See also
Usage examples at execute().

◆ insert() [2/3]

TableInsert insert ( List  columns)

Initializes the record insertion handler with the received column list.

Returns
This TableInsert object.

This function is called automatically when Table.insert(List columns) is called.

Method Chaining

After this function invocation, the following functions can be invoked:

  • values(Value value1, Value value2, ...)
  • execute().
See also
Usage examples at execute().

◆ insert() [3/3]

TableInsert insert ( String  col1,
String  col2,
  ... 
)

Initializes the record insertion handler with the received column list.

Parameters
col1The first column name.
col2The second column name.
Returns
This TableInsert object.

This function is called automatically when Table.insert(String col1, String col2, ...) is called.

A string parameter should be specified for each column to be included on the insertion process.

Method Chaining

After this function invocation, the following functions can be invoked:

  • values(Value value1, Value value2, ...)
  • execute().
See also
Usage examples at execute().

◆ values()

TableInsert values ( Value  value1,
Value  value2,
  ... 
)

Adds a new row to the insert operation with the given values.

Returns
This TableInsert object.

Each parameter represents the value for a column in the target table.

If the columns were defined on the insert function, the number of values on this function must match the number of defined columns.

If no column was defined, the number of parameters must match the number of columns on the target Table.

This function is not available when the insert is called passing a JSON object with columns and values.

Using Expressions for Values

If a mysqlx.expr(...) object is defined as a value, it will be evaluated in the server, the resulting value will be inserted into the record.

Method Chaining

This function can be invoked multiple times after:

After this function invocation, the following functions can be invoked:

See also
Usage examples at execute().

◆ execute()

Result execute ( )

Executes the insert operation.

Returns
A Result object that can be used to retrieve the results of the operation.

Method Chaining

This function can be invoked after:

  • values(Value value1, Value value2, ...)

Examples