Declaring Variables LIKE Columns

If you use the LIKE clause, the database server assigns the variable the same data type as a specified column in a table, synonym, or view.

The data types of variables that are defined as database columns are resolved at runtime; therefore, column and table do not need to exist at compile time.

You can use the LIKE keyword to declare that a variable is like a serial column. This declares:

For example, if the column serialcol in the mytab table has the SERIAL data type, you can create the following SPL function:
CREATE FUNCTION func1()
DEFINE local_var LIKE mytab.serialcol;
RETURN;
END FUNCTION;

The variable local_var is treated as an INTEGER variable.


Copyright© 2021 HCL Technologies Limited