Expressions as host variables

Host variables must be simple names because the SQL preprocessor does not recognize pointer or reference expressions. For
example, the following statement does not work because the SQL preprocessor does not understand the dot operator. The same syntax has a different meaning in SQL.

Although the above syntax is not allowed, you can still use an expression with the following technique:

Wrap the SQL declaration section in an #if 0 preprocessor directive. The SQL preprocessor will read the declarations and use
them for the rest of the module because it ignores preprocessor directives.

Define a macro with the same name as the host variable. Since the SQL declaration section is not seen by the C compiler because
of the #if directive, no conflict will arise. Ensure that the macro evaluates to the same type host variable.

The following code demonstrates this technique to hide the host_value expression from the SQL preprocessor.

Since the SQLPP processor ignores directives for conditional compilation, host_value is treated as a long host variable and will emit that name when it is subsequently used as a host variable. The C/C++ compiler processes the emitted
file and will substitute my_s.host_field for all such uses of that name.

With the above declarations in place, you can proceed to access host_field as follows.