You can use the SET command to set the value of a variable equal to an expression.
SET @variablename = expression
SET @var1 = 5+5
SET @var1 = 5+(20*3)
SET @var2 = @var1+50
An important feature of variables is that they can be used inside the SQL of IMPORT statements.
When the import statement uses an TARGITDB type datasource, a single Declare and Set can be made at the beginning of the .imp file, otherwise a variable to be used in a query from an external source must be declared and set within the IMPORT brackets.
DATASOURCE Source1 = ODBC 'odbc_connection_X'
IMPORT orders = source1.orders
/* Say we want to create another order table with a specific subset of items only... */
IMPORT orders_some_only = ME.
DECLARE @cSupp1 AS STRING
SET @cSupp1 = “Smiths Sweets Inc.”
SELECT * FROM ORDERS AS o1 WHERE o1.Supplier = @cSupp AND o1.Office = @param1
/* Notice we did not have to declare @param1 since it is a system function, in this case created when we called the ‘mysample2.imp’ import script */