Parameter substitutions in DML statements

<< Click to Display Table of Contents >>

Navigation:  Local SQL > Data Manipulation Language > Parameter substitutions >

Parameter substitutions in DML statements

Previous pageReturn to chapter overviewNext page

 

Parameter markers can be used in DML statements in place of data values. Parameters are identified by a preceding colon (:). For example:

SELECT last_name, first_name

FROM "Customer.db"

WHERE (last_name > :lname) AND (first_name < :fname)

Parameters allow the same SQL statement to be used with different data values to be used for comparisons. Parameters are placeholders for data values. At runtime, the front-end application fills the parameter with a value, before the query is executed. When the query is executed, the data values passed into the parameters are substituted for the parameter placeholder and the SQL statement is applied.

Parameters are used to pass data values to be used in WHERE clause comparison and as update atoms in updating statements. Parameters cannot be used to pass values for metadata object names (table and column names).

UPDATE Orders

SET ItemsTotal = :TotalParam

WHERE (OrderNo = 1014)

Data values passed to SQL statements as parameters are enclosed in quotation marks (where applicable). Thus, when a front-end application supplies CHAR and DATE values for parameters, quotation marks need not be included when the parameter is populated with the values.