SetNamedVariable method (DominoQuery - Java)

Assigns a value to a named substitution variable in a DQL query.

Syntax

void setNamedVariable ( String name, Object value ) throws NotesException

Parameters

String name

The name of the variable coded in a DQL query, following the ?. (Example "? orig_name" would appear as ?orig_name in the DQL query)

Object value

A value to be processed as Text, Number or Datetime in DQL. Since DQL data typing is determined by value type and not field type, the type of the value passed in determines the kind of value searching DQL will perform.

Returned value

None

Usage

Binds a value to a named substitution variable in a DQL query. If there is already a bound value for the name specified, an error is returned. In that case, you must call ResetNamedVariables to clear the variable state.

SetNamedVariable allows query syntax to remain static while values being processed change. It is part of a strategy to avoid a SQL Injection attack wherein users pass in values to be processed but can also change query syntax if a query is built on the fly. Since the query text remains static, this security exposure is circumvented.

For more information on substitution variables, see the Domino Query Language documentation.

Language cross-reference

SetNamedVariable method (NotesDominoQuery - LotusScript)