An ODB API file cannot be changed in place. Instead, a new version of the file has to be created with the desired modifications.

Sometimes all we need to do is to add a constant column. This is often needed before archiving or transferring the file to a different organization, as we want to make the data on file self-describing, and so we need to include in it constants representing experiment version, origin, etc. To achieve this the simplest solution is to use the 'odb sql' command line tool, for example:

Create a new version of a file with an added constant column using command line odb tool
$ odb sql 'select *, 1 as mf_vertco_type' -i in.odb -o out.odb -f odb

will create a new version of file "in.odb" with added constant column mf_vertco_type and save it in file "out.odb".

In case we want the new column to be of type INTEGER, rather than the default type REAL, we can do:

Create a new version of a file with an added constant integer column using command line odb tool
$ odb sql 'select *, int(1) as mf_vertco_type' -i in.odb -o out.odb -f odb

This technique is limited to adding columns with constant values or values that are derived from other columns of the input file and can be described as expressions supported by ODB API SQL. In case we want to populate the added column(s) with some arbitrary values we need to write a program that reads the input file and writes output file with the added columns. This can be done with any of the currently supported languages: Python, C, C++ or Fortran.