01-28-2020, 02:52 PM
Finding the negative is always more difficult. You could use this:
@SOBJECT(prod/asset['code','not in',@GET(sthpw/task['search_code','like','ASSET%'].search_code)])
Because the two are in different databases, the sql statement produced will be rather large if you have a lot of assets. This is one reason that I filter the tasks for search_codes starting with 'ASSET%' first. If Postgresql could join between databases like some other databases, this operation would be much more efficient.
... but it should work and postgres is very tolerant of very large sql statements.
If you actually want to see what sql is being produced from an expression, you can always use the SEARCH command:
from pyasm.search import Search
expr = "@SEARCH(prod/asset['code','not in',@GET(sthpw/task['search_code','like','ASSET%'].search_code)])"
search = Search.eval(expr)
print(search.get_statement())
This is a good way of diagnosing exactly what the expression language is doing.
@SOBJECT(prod/asset['code','not in',@GET(sthpw/task['search_code','like','ASSET%'].search_code)])
Because the two are in different databases, the sql statement produced will be rather large if you have a lot of assets. This is one reason that I filter the tasks for search_codes starting with 'ASSET%' first. If Postgresql could join between databases like some other databases, this operation would be much more efficient.
... but it should work and postgres is very tolerant of very large sql statements.
If you actually want to see what sql is being produced from an expression, you can always use the SEARCH command:
from pyasm.search import Search
expr = "@SEARCH(prod/asset['code','not in',@GET(sthpw/task['search_code','like','ASSET%'].search_code)])"
search = Search.eval(expr)
print(search.get_statement())
This is a good way of diagnosing exactly what the expression language is doing.