Skip to main content

DB_Table.set

setvalueas set_mode on_problems

Group: Values
Aliases: add column, expression, formula, new column, update column

Documentation

Sets the column value at the given name.

Arguments

  • value: The value, expression or column to create column.
  • as: Optional new name for the column.
  • set_mode: Specifies the expected behaviour in regards to existing column with the same name.
  • on_problems: Specifies how to handle problems with expression evaluation.

Examples

Create a table where the values of the total stock in the inventory is

doubled.

      import Standard.Examples

example_set =
table = Examples.inventory_table
double_inventory = table.at "total_stock" * 2
table.set double_inventory as="total_stock"
table.set (expr "2 * [total_stock]") as="total_stock_expr"

Errors

  • If the column name is already present and set_mode is Add, a Existing_Column dataflow error is raised.
  • If the column name is not present and set_mode is Update, a Missing_Column dataflow error is raised.
  • If a column name referenced from within an expression cannot be found, a No_Such_Column dataflow error is raised.
  • If the provided expression is invalid, a corresponding Expression_Error dataflow error is raised.
  • The following problems with expression evaluation may be reported according to the on_problems setting:
    • If the expression checks equality on a floating-point column, a Floating_Point_Equality.
    • If an arithmetic error occurs when computing the expression, an Arithmetic_Error.
    • If more than 10 rows encounter computation issues, an Additional_Warnings.