What function adds a row?
Adding a row is done using the insert function. If only the table is specified, a row will be added where the fields will be filled with their default values, codes, and codes on addition.
If the field
parameters are specified, these values will have the highest priority:
=: insert(table: 'table'; field: 'field_1' = $value1; field: 'field_2' = $value2)
value1: 10
value2: "Cool text"
How do I add multiple rows with different data?
Adding multiple rows is done using the insertList function. To insert different values into different rows, lists of values should be passed to the field
instead of single values:
=: insertList(table: 'table'; field: 'field_1' = $listValue1; field: 'field_2' = $listValue2)
listValue1: listCreate(item: "value_1_1"; item: "value_1_2"; item: "value_1_3")
listValue2: listCreate(item: "value_2_1"; item: "value_2_2"; item: "value_2_3")
How do I delete a row?
To delete a single row, the function delete is used. It will delete only one row that matches the condition:
=: delete(table: 'table'; where: 'id' = $#nfv)
How do I delete several rows?
The function deleteList is used. It will delete all rows that match the condition:
=: deleteList(table: 'table'; where: 'type' = 4)
How do I delete all rows in a table?
Specify that you need to delete all rows where id
is not equal to 0
:
=: deleteList(table: 'table'; where: 'id' != 0)
Or do not specify the where
parameter at all (but it's better not to do this with deletion — specifying where
is more readable!).
Is there an undo in Totum?
No!
Which rows will be deleted if the deleteList function is used without the where parameter?
All rows will be deleted - be careful!
How can I combine adding rows by code and calculating values in subsequent fields by code?
If you are adding a row to a table that has many fields in the row part, the correct approach is to pass the data array row
to the leading technical field of type Data
and parse the value from it using code.