Home > Contents > Index >
searchstate:addlikeconstraint
Adds a list of attribute
like
name/value constraints into a new or existing searchstate object.Syntax
<searchstate:addlikeconstraint name="ssname" [bucket="bucketname"] [typename="assettype"] attribute="attribname" [list="listname"] [immediateonly="true|false"] [caseinsensitive="true|false"]/>Parameters
name
(required)- Input parameter. Name of an object representing a searchstate.
bucket
(optional)- Input parameter. Bucket name. If not specified, the attribute name is used. Use this parameter to indicate which constraint you need when the same attribute is used in multiple contstraints. A bucket is an alias and functions similar to an inner join in SQL; when you have multiple tables that have columns of the same name, you must specify the table name to indicate which column you are requesting.
typename
(optional)- Input parameter. Internal asset type name for the attribute (either
CAttributes
for content attribute, orPAttributes
for product attribute). If you do not specifyTYPENAME
, a default value is picked up from a property in thegator.ini
property file:mwb.defaultattributes
. The default value is set to bePAttributes
and may be changed to be the name of any custom attribute asset types you create.
attribute
(required)- Input parameter. Name of the attribute to constrain.
list
(optional)- Input parameter. A list of the constrained values for the attribute. If specified, one or more of the values must match the attribute for a product to meet the constraint. The default is that all assets that have any value for the attribute match the constraint.
immediateonly
(optional)- Input parameter.
true
indicates that the search is limited to values directly associated with the specified attribute;false
(the default) extends the search to include values inherited from a parent.
caseinsensitive (optional)
- Input parameter.
true
indicates that the comparison is case-insensitive;false
(the default) considers case in the comparison.
Description
The
searchstate
object referred to byname
is updated to include the new constraint specified by this tag. This constraint is similar to a databaseLIKE
operation and accepts wild cards (%). If the attribute name is already in the searchstate, then the new constraint replaces the old constraint.Error Numbers
The possible values of
errno
include:
Value Description -10004 A required parameter is missing. -13050 General error: usually fields or columns of a resultset or list are not as expected.Example
This code creates an empty
searchstate
and adds a like constraint. The constraint sets theattribute
to search on but does not specify alist
of values to match against. Thetypename
parameter is not specified and the default set in gator.ini is picked up. Any assets with values for this attribute will be returned as matches for this constraint. This code then sets thissearchstate
into anassetset:setsearchedassets
tag to constrain theassetset
to be used when searching with other assetset tags. The last tag uses this constrained assetset to search for matching assets and fetch a list of values for a different attribute of the returned assets:<searchstate:create name="ss" /> <searchstate:addlikeconstraint name="ss" attribute="cat2" /> <assetset:setsearchedassets name="as" constraint="ss" assettypes="Products"/> <assetset:getattributevalues name="as" attribute="productdesc" listvarname="resultlist"/> <ics:listloop listname="resultlist"> <ics:listget listname="resultlist" fieldname="value"/><br/> </ics:listloop>This code sets a list which contains two values to match into the like constraint. The final resultlist will contain a subset of the results in the previous example:
<listobject:create name="lo" columns="value" /> <listobject:addrow name="lo"> <listobject:argument name="value" value="Germicidal Lamps"/> </listobject:addrow> <listobject:addrow name="lo"> <listobject:argument name="value" value="Watt%"/> </listobject:addrow> <listobject:tolist name="lo" listvarname="matchlist"/> <searchstate:create name="ss" /> <searchstate:addlikeconstraint name="ss" attribute="cat2" list="matchlist"/> <assetset:setsearchedassets name="as" constraint="ss" assettypes="Products"/> <assetset:getattributevalues name="as" attribute="productdesc" listvarname="resultlist"/> <ics:listloop listname="resultlist"> <ics:listget listname="resultlist" fieldname="value"/><br/> </ics:listloop>See Also
searchstate:create
searchstate:addsimplelikeconstraint
searchstate:addsimplestandardconstraint
assetset:setsearchedassets
assetset:getattributevalues
ListObjects
Home > Contents > Index > ![]()
Oracle JSP Tag Reference
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.