PRINTF

fun PRINTF(format: String, vararg columns: KQLiteColumn<*>): KQLiteColumn<String>

Formats a string using a C-style printf() format string.

This function corresponds to the printf(format, ...) function in SQLite. It returns a string formatted according to the format string, which contains substitution markers like %d, %s, etc. These markers are replaced by the values from the subsequent arguments (x, xn).

Key differences from the FORMAT function:

  • If there are more format specifiers than arguments, the extra specifiers are filled with NULL.

  • If there are more arguments than format specifiers, the extra arguments are ignored.

  • It does not reuse arguments.

Example

// SELECT printf("ID: %04d, Name: %s", id, name) FROM Users
val query = select(PRINTF("ID: %04d, Name: %s", Users.id, Users.name)).from(Users)

Return

A KQLiteColumn of type String containing the formatted result.

Author

MOHAMMAD AZIM ANSARI

Parameters

format

The C-style format string.

columns

Columns or values for substitution.

See also