ORDA queryByFormula?

Is there currently (as of 17r6) a way to do an ORDA queryByFormula? (similar to the new OrderByFormulal)

Hey Tony,

You know the basic collection.query() or ds.TABLE.query() offer everything QBF does for me. What kinds of things are you thinking of?

Kirk
So far, my question is theoretical.
However, If I make a Formula object, for code consistency, I’d like to be able to use it for both Ordering and querying.

I’m sure I’ll think of specific application in the future where QueryByFormula would have uses.

Tony,

I see. I think I would do that by having a separate method for query and ordering. They could each take the same parameters but the two are different operations. And you could put both of them in the same object.

I make such objects sometimes like:
<code 4D>
$obj:=New object

$obj.table:="My_Table"

$obj.query:=Formula(z_generic_query($1))
$obj.orderBy:=Formula(z_generic_orderBy($1))
$0:=$obj

</code 4D>

The z_generic_query method could look something like:
<code 4D>
C_OBJECT($1)
C_OBJECT($0;$temp_sel)
c_Text($queryStr)

$queryStr:=< analyze the params in $1 >

$temp_sel:=ds[This.table].query($queryStr)
    $0:=$temp_sel

</code 4D>

Since z_generic_query runs in the context of the object formula you can use This to access anything stored in that object.

Just offering some ideas here. This is all really new stuff. I know I’m still working out what’s useful and what’s not.

I just noticed my original post trimmed some of the text in the query method code. My point is you look at the contents of the object and build the query string. That will most likely be a lot more than a line or two of code.

Hi,

Since V17R6, the query member method on dataclass and entity selection has been updated to support formulas.

https://doc.4d.com/4Dv17R6/4D/17-R6/dataClassquery.305-4311816.en.html

https://blog.4d.com/more-sophisticated-orda-queries-with-formulas/

Thank you Marie, That’s exactly what I needed!