Host Variables and their UsageThe host language variables that are used in the ESQL statements appearing in an ESQL program are called host variables. Host variables must be declared in the declare section prior to its usage in an ESQL program. The data types used to declare the host variables can be the same as database types. For example, to declare a host variable of type SHORT, the variable can be declared as the database type SMALLINT. The general format of using the host variable in an ESQL construct is shown below: :host_variable_name When a host variable is used in the ESQL constructs, the variable has to be prefixed with a colon. The following sample ESQL code shows the usage of host variables: ... EXEC SQL INSERT INTO orders (order_no, order_date, product, qty) VALUES (:order_no_v, :order_date_v, :product_v, :qty_v) ; ... In the above example, it can be seen that whenever host variables are used, they are prefixed with a colon. The host variables can also be used by C language statements as and when desired. Keep the following points in mind while using host variables in ESQL. Host variables must:
Indicator variables are discussed in the following section. |
|||