Enum in where clause in OQL query

0
Hi Team,Im trying to use the OQL query in Execute OQL statement (Count rows ) in version 11.12.2. Can any one suggest me the query.I tried multiple values of having the where clause for status field, but no luck.Current Query statement is -'SELECT * FROM Example.Customer WHERE Status = "Pending"'Note - In my enum values both the caption adn key are same type.Appreciate your help!Thank you!
asked
2 answers
1

The enum value should be in single quotes. If you're building the query string in the modeler you'll need to escape the single quotes inside the string with, get this, single quotes. So try something like:

'SELECT * FROM Example.Customer WHERE Status = ''Pending'''

Note that this only contains single quotes.

The executed OQL statement should then be:

SELECT * FROM Example.Customer WHERE Status = 'Pending'


Also if you only want to know how many there are, you may just as well retrieve from database using xpath and do a count. Mendix will automatically optimize this so it only retrieves a count, not a list of objects.

answered
0

Hi Jhansi,

As Martin said,

I tried the same syntax in the OQL playground.

https://service.mendixcloud.com/p/OQL

By using sytax

SELECT  FirstName FROM Sales.Customer WHERE CustomerType = 'FirstTimer'

and it's wokring there.


can you please check your enum attribute again.

answered