OQL query with case expression

0
Hello, I'm trying to do a simple OQL query with a case expression. I follow this tutorial : https://world.mendix.com/display/refguide3/OQL+Case+Expression Unfortunately, I have always an error when I launch my query. Could I have a simple and concrete example of an OQL query using a case ? This is an example of what I tried : CASE SELECT Person WHEN 1 THEN 'one' ELSE 'two' Best regards.
asked
2 answers
3

The CASE statement should fit where a column does in an OQL query. If your basic query looks like this:

SELECT Name
FROM ModuleName.Person

The output from this might look like:

  • John
  • Frank
  • Sally

If you replaced your selection of the Name attribute with a CASE statement, it would look like this:

SELECT CASE Name WHEN 'John' THEN 1 ELSE 0
FROM ModuleName.Person

The output from this query would look like:

  • 1
  • 0
  • 0

Hope that helps!

answered
0

Ok I understand the syntax.

Thank you, it helps a lot !

answered