PARAMETERS Declaration (SQL Only)

See AlsosqlParametersSee                 ExamplesqlParametersExample>Low


For queries that you run regularly, you can use a PARAMETERS declaration to create a parameter queryG72497.  A parameter query can help automate the process of changing query criteria.  With a parameter query,  you can set new values for the parameters each time the query is run.

In the Professional Edition only, you can set QueryDef parameters with the following syntax:

          querydef ! parametername = parametertext


The PARAMETERS declaration is optional but when included precedes any other statement, including SELECT.

You use the following syntax to declare a parameter:


          PARAMETERS parametertext datatype


The argument parametertext is the name of the parameter you use in the SQL statement29F05E5.  Use brackets to enclose text that contains spaces or punctuation.  For example, [Low price] and [Begin report with which month?] are valid entries for parametertext.

The argument datatype is the parameter's field data type17F82T4.

If the declaration includes more than one parametertext-datatype pair, separate them with commas.  The following example includes two parameters:


PARAMETERS [Low price] Currency,
[Beginning date] DateTime


You can use parametertext but not datatype in places such as a WHERE or HAVING clause.  The following example requires that your program supply two parameters and then applies the criteria to records in the Orders table:


PARAMETERS [Low price] Currency, [Beginning date] DateTime;
SELECT [Order ID], [Order Amount]
FROM Orders
WHERE [Order Amount] > [Low price]
AND [Order Date] >= [Beginning date]