execute

abstract fun execute()

Executes the prepared INSERT statement.

This function finalizes and runs the INSERT query that has been configured using bind, values, or select. After this call, the new row will be inserted into the table.

This method does not return any value. If you need to retrieve data from the newly inserted row (like an auto-generated primary key), use executeReturning instead.

The statement is executed when this function is called. A use block is recommended to ensure resources are automatically closed after execution.

Example:

// Using values()
Artists.insert(Artists.artistName).use { statement ->
statement.values("A New Band").execute()
}

// Using bind()
Artists.insert().use { statement ->
statement.bind { it.artistName.bind("Another Band") }.execute()
}

Author

MOHAMMAD AZIM ANSARI

See also

Throws

if no data has been provided via bind, values, or select, or if a database error occurs during insertion (e.g., constraint violation).