Tuesday, June 9, 2009

Using "const" for reserved words in SEARCHES

Reserved words such as keywords and select expressions must be afforded special consideration in exact equal (==) Matrix expressions. For example, the following statement might be written to find business objects where the value of the attribute ‘Regression’ is ‘first’.
where 'attribute[Regression]==first';

But because ‘first’ is a select keyword that returns the first revision of a business object and is evaluated as such, the result of the evaluation — rather than the literal word ‘first’— is compared with the attribute.

For this type of situation, use const to indicate that whatever follows should not be evaluated.

For example: where 'attribute[Regression]==const"first"';

Const has three possible forms: all uppercase, all lowercase, and initial letter capitalized followed by all lowercase. No space can appear after the word const. It must be followed by a quote (double or single, depending on the syntax of the rest of the statement). Almost any character can appear within the quotes, with the exception of backslash and pound sign. The characters between the initial and closing quotes remain unevaluated.

If your implementations are using JSP/Tcl to compose a where clause dynamically (that is, using a variable to construct the where clause), the const syntax must be used because the value you pass in could be a ENOVIA Collaboration Platform keyword. If this happens, the where clause will not return an error, but you will get unexpected results.
Here are some examples of queries that will NOT return correctly without using const:

attribute[Some Attribute]==‘first’
attribute[Some Attribute]==‘FIRST’
attribute[Some Attribute]=="Current"
attribute[Some Attribute]=="owner"
description=="Current"
description=="policy"

However, the following will return correctly:

attribute[Some Attribute]==‘my first order’
attribute[Some Attribute]~=‘*first*’

No comments:

Post a Comment