Lucee Tag Reference
<cfqueryparam>
Checks the data type of a query parameter. The cfqueryparam tag is nested within a cfquery tag and embedded within the SQL statement.
This tag:
- Improves security by preventing SQL injection attacks
- Provides data validation for parameter values
- Enhances performance by enabling database query caching
- Correctly handles type conversion between CFML and database types
Body
This tag can't have a body.
Example
<cfqueryparam [cfsqltype=string] [charset=string] [list=boolean] [maxlength=number] [null=boolean] [scale=number] [separator=string] [sqltype=string] [value=any]>
This tag is also supported within cfscript
<cfscript> queryparam [cfsqltype=string] [charset=string] [list=boolean] [maxlength=number] [null=boolean] [scale=number] [separator=string] [sqltype=string] [value=any]; </cfscript>
Attributes
The attributes for this tag are fixed. Except for the following attributes no other attributes are allowed.
| Name | Type | Required | Description |
|---|---|---|---|
| cfsqltype | string | No | This Attribute is deprecated |
| charset | string | No | Specifies the character encoding for string validation. This attribute serves two purposes: 1. It validates that the given value is compatible with the specified charset 2. It determines how byte length is calculated for `maxLength` validation Common values include `UTF-8`, `ISO-8859-1`, or other valid Java charset names. |
| list | boolean | No | Controls how the parameter value is handled: When working with lists/arrays: |
| maxlength | number | No | Maximum allowed length of the parameter value (validation check). |
| null | boolean | No | Indicates whether the parameter should be treated as NULL. SQL comparison with NULL requires special syntax in most databases (using `IS NULL` rather than `= NULL`). |
| scale | number | No | Number of decimal places to allow for numeric parameters. |
| separator | string | No | Specifies the character that separates values in string lists. Note: For best results with complex separators or values that might contain the separator character, consider using an array instead of a delimited string. |
| sqltype | string | No | The SQL data type that the parameter will be bound to. Common types include: Using the correct type improves security, enables proper type checking, and optimizes query execution. |
| value | any | No | Specifies the actual value that Lucee passes to the database. The value will be automatically escaped to prevent SQL injection. |