How to add search criteria to existsing "select" query

I have an std class that uses “select” query to calculate the data.

There is already existing criteria in that query, that looks like:

select Field A, Field B from Table

where Table.InventTransId = _inventTransId

But I need to pass several invent trans into this method to filter( not only by one)

so basically i need something like where Table.InventTransId not in ( _inventTransId1, _inventTransId2, _inventTransId3)

Is there any simple way of doing this?

(It could be nice if it was a queryBuild -based query, of course, but it’s not in this case)

If you want to build queries dynamically, use the Query framework. For example:

Query query = new Query();
QueryBuildDataSource ds = query.addDataSource(tableNum(YourTable));
ds.addRange(fieldNum(YourTable, InventTransId))
    .value(queryValue(_inventTransId1));
ds.addRange(fieldNum(YourTable, InventTransId))
    .value(queryValue(_inventTransId2));

Alternatively, you can get data in a TempDB table and join it with your table.

Hi Martin

Thank you for the reply, but as I said it’s std functionality and i can’t use QBDS there (I don’t fancy rewriting all thing)

Tmp table is an option of course, but there are already 5 tables joined by various joins so I’m cautious of joining a Tmp now(, but looks like it’s the only solution