Using Column Variables in Conditions
You can name database columns with variables and use their values in conditions and commands.
When you select columns from the database in a select paragraph, you can immediately print them by using a position. For example:
begin-select
phone (,1)
position (+1)
from customers
end-select
This example shows how to use the value of phone for another purpose, for example, in a condition:
begin-program
do list_customers
end-program
begin-procedure list_customers
begin-select
phone
if &phone = ''
print 'No phone' (,1)
else
print &phone (,1)
end-if
position (+1)
from customers
end-select
end-procedure ! list_customers
The phone column is a SQR column variable. Precede column variables with an ampersand (&).
Unlike other program variables, column variables are read-only. You can use their existing value, but you cannot assign a new value to a column variable.
In the sample program, &phone is a column variable that you can use in SQR commands as if it were a string, date, or numeric variable, depending on its content. In the example condition, &phone is compared to ' ', which is an empty string. If &phone is an empty string, then the program prints No phone.