2010年11月14日星期日

View Object’s query criteria

section 1. using basic columns and operators

It’s easy to configure a query criteria and a bind variable in the View object to query like :

select * from candidate_answers where question_id = :VariableQuestionId

The bind variable can be settled with a default value, without a settled default value, the default value defaults to null.

section 2. using database functions to column like length(description) >5

It’s a little trick to configure a query criteria and a bind variable in the View Object to query like:

select * from candidate_answers where

length(description) >= :VariableDescriptionLength.

A. first configure an additional attribute in the VO, named DescriptionLength as a ‘Mapped to Column or SQL’.

B. everything then goes the same as the simple criteria in section 1.

C. check the View Object Where clause sub-window in the Create Criteria Window to make sure that the expected SQL is issued.

From this criteria, we can see that a View object is really a view query for the database, everything is from the entity object or the query. VO can be flexibly set to fulfill the requirement.

I don’t know if there is other way to fulfill the various expected SQL query in the VO by criteria.

section 3. Test the criteria in the business component browser.

use the Criteria icon in the BC Browser to set the bind variable.