I'm converting old 4D code from class queries to ORDA queries. One thing I can't figure out is how to query with a field vs a field, rather than a field vs a value.
Edit: I'm using 4D v17.4.
Classic:
Query([Customers];[Customers]State="IN")
ORDA:
ds.Customers.query("State = 'IN'")
I want to be able to query a table for results where I'm comparing a field value vs another field value. I can do it in classic querying via the following:
Query([Customers];[Customers]State#[Customers]AdministrativeRegion)
ds.Customers.query("State # AdministrativeRegion") // DOESN'T WORK
Is this possible?
You didn't mention which version of 4D you are using. 4D is changing very rapidly these days and the difference between them can really matter, though in this case not as much.
Using placeholders in your query string is the first step.
Instead of
ds.Customers.query("State # AdministrativeRegion")
do
ds.Customers.query("State # :1 ";"some value")
Each placeholder is referenced by the :n syntax starting at 1. This is a big benefit because 4D will manage converting the comparison value data type. This is also the key to referencing a value in an entity, object, formula, etc.
$entity_selection:=ds.Customers.query("State # :1";$entity.State)
where $entity
is the one you want to compare to.