Basic types using loop function fn_computed_col
No coding an no parameter is necessary in 2 cases (most common cases):
1/ text 1 to 1 relationship, get the department of an item (type A)
2/ coefficient 1 to 1 relationship, get price from qty using item price (type B)
SB parameter
set
COMPUTED_COLUMNS='comp_col1,comp_col2,...'
SB C interface
SB needs 2 functions per computed column
1/ <comp_col_name>_before
2/ <comp_col_name>
See input/output of these functions in common.h
priority between computed column and real column
By default real column has priority over a computed column with same name
computed column basics
New_customer_id is a computed text column
Its destination col_type is t_customer_id
We are going to return always the same value
So we don't need other columns to compute new_customer_id in this basic case
Please note that needed_col_count can't be zero, because on the in/out value at first position
Hence needed_col_names=["dept"]
computed columns with analytic function
computed columns with param
optimized contexts (type A)
optimized contexts (type B)
using other columns
New_customer_id will be equal to the first customer_id will have 2 values:
1/ current customer_id if item_id is artA (ival=10)
2/ null otherwise
using other columns (better code)
Dept was here for clarity (in/out value), let's remove it, and use customer_id instead
And we won't need to update the new in/out in case 1/ because it is already good
SB predefined contexts C API
A context is a C custom objects stored in memory be SB ant that can be used by other part of your custom C code
Some predefined contexts for most common operations are provided (see common.h)
using context basics
Sometimes your computed column will need other information because the needed columns in not enough
Context should be used in that case
using custom context
Sometimes predefined context is not enough, or you needed several custom contexts
In such cas you should define your own context
using indexes on computed columns
Index can be used if there is only one needed column and that this column has an index (is part of a dimension)