How to use enumeration in OQL where clause.

1
I am trying to filter out values based on the value on Enumeration, I am unable to figure the syntax for it in OQL. The documentation doesn’t have any info.
asked
2 answers
5

Enumerations are stored as strings in the database. The values of the enumeration are the values that are stored, so I think you should write your OQL treating the enum like a string.

So if your attribute called Priority has the possible values and captions like this:

1_Low            Low

2_Medium    Medium

3_High           High

Then your query would be like:

WHERE Priority=’1_Low’

 

answered
0

https://forum.mendix.com/link/questions/90339 gave me a good lead

function getCaption() extract enumeration value usable in OQL statement

'
select 
    ContentNo as entityId,
    Title as Title,
    ShortDescription as Description,
    ContentType as Origin,
    NoLikes as NoLikes,
    NoViews as NoViews,
    NoRate as NoRates
from General.Content
where' + 
'    (Title like ' + '''%' + 
$TempSearch/searchInput
+ '%''' +
'    or ShortDescription like ' + '''%' + 
$TempSearch/searchInput
+ '%''' +
'    ) and (ContentType = ' +  '''' + 
getCaption($TempSearch/ContentType)
+ ''')'

 

answered