Search code examples
javasqlodataolingo

Filtering by value list in OData service


So, suppose I have a an SQL table:

create table Person(id varchar2(255) not null);

I'm trying to wrap it using Apache Olingo.

Is it possible to express this SQL query in OData??

select * from Person where id in ('a1', 'a2', 'a3', ... 'an');

My first try was to use a multiple OR filter, like so:

http://myserver:8080/odata/Person?$filter=(id eq '0000022AC58540EA') or (id eq '00001CD8D55ED552') or (id eq ‘000027F7F21A6196')

But this gives me the following error:

<error>
  <code/>
  <message xml:lang="en-US">
    Invalid filter expression: '(id eq '0000022AC58540EA') or (id eq '00001CD8D55ED552') or (id eq ‘000027F7F21A6196')'.
  </message>
</error>

This answer suggests using a combination of AND and ANY predicates to more or less achieve the same effect. Is this there another way to translate the aforementioned SQL query?

Thanks!


Solution

  • As Yi commented, the query is perfectly fine, I believe you get the error because you used the wrong single quote in your last or statement:

      ‘000027F7F21A6196'
    //^