Dictionaries
Inserting Dictionary Into Table
A single new record is naturally represented as a dictionary — insert and Join (,) are the two main ways to add one to an existing table.
insert
insert[`tableName;recordDict]insert matches the dictionary's keys to the table's column names. Any column not present in the dictionary is filled with the appropriate null value for its type, and the table is updated in place.
t:([] orderId:1 2 3; qty:100 200 300; price:10.5 11.0 11.5)
order:`orderId`qty!(4;150)
insert[`t;order]torderId qty price
-----------------
1 100 10.5
2 200 11
3 300 11.5
4 150The new row's price is a float null (0n), which the console displays as a blank.
Join (,)
A table can also be extended by joining (,) it with a conforming dictionary — one containing a value for every column. Keys are matched to columns by name, so their order does not matter; if a column is missing, the join fails with 'mismatch. If a column is missing from the dictionary, build a small dictionary for it (with a typed null value) and join the pieces together before joining onto the table.
insert is generally the simpler, more idiomatic choice for appending a single record; Join is useful when the complete record needs to be assembled from several sources first.