Using Query Equation(I)

Discussions on ExtendSim's integrated database
Post Reply
velcro
Posts:31
Joined:Thu Apr 15, 2010 8:49 am
First Name:Steve
Last Name:Cohen
Using Query Equation(I)

Post by velcro » Tue Apr 14, 2020 8:42 am

I am trying to use the database to find records that match criteria. It seems the way to do that is the Query Equation block.

I can create an equation that ranks each record, and assign that to the DBQ record rank. But I want to know the record number of the best rank. How do I access that? Is there any way to access ranks for all the records?

The fallback is to do ignore Query Equation blocks and just use Equation blocks to do manual searches with loops. Is that more computationally intensive? At that point is there any advantage of Databases over Global Arrays, other than parent/child relationships?

Thanks,

Steve

nastasiaj
Posts:5
Joined:Mon May 01, 2000 12:00 am
First Name:Anthony
Last Name:Nastasi

Re: Using Query Equation(I)

Post by nastasiaj » Tue Apr 14, 2020 3:14 pm

Hi Steve,

There's an input variable called "DBQ_CurrentRecordIndex. Use that to know which record in your query table the equation is currently calculating on.

On the options tab, you can specify what to do with the the rank, ie, which record wins.

Also, if you want to write some kind of result to every record in your query table (like its ranking), you can use the DBQ Write output variable. So in this case you don't need the DBQ_CurrentRecordIndex input variable because the block will take care of that for you.

Also, if you want results or rankings from every record in your query table, you can spawn records as items and store attributes on those items. You turn on spawning from the Options tab.

Call me if you have questions. I'm happy to discuss the block with you.

Anthony Nastasi
408-365-0305 x7213

velcro
Posts:31
Joined:Thu Apr 15, 2010 8:49 am
First Name:Steve
Last Name:Cohen

Re: Using Query Equation(I)

Post by velcro » Wed Apr 15, 2020 8:30 am

Anthony,

Thanks for the reply. I am a little confused about the input variable DBQ_CurrentRecordIndex. If it tells me the record the equation is currently calculating on, it seems like it will just give me values from 1 to #records. How do I know which one of the iterations is the "best" one so I can grab that record number?

Part of the confusion is that this record number is created internally, as are outputs, and not brought in from outside, as are inputs, so I did not expect to see that in the input section.

Thanks,

Steve

nastasiaj
Posts:5
Joined:Mon May 01, 2000 12:00 am
First Name:Anthony
Last Name:Nastasi

Re: Using Query Equation(I)

Post by nastasiaj » Wed Apr 15, 2020 7:38 pm

Hi Steve,

Yes, this block is not for the faint of heart. Have you studied the Query Equation's block help? I'm biased because I wrote it, but I think the first two paragraphs of the block help would be helpful. Also, I really do encourage you to call me: 408-365-0305 x7213. I'm really happy to setup a mini training session with you.

But to answer your question (and this will be described better in the block help), the equation executes multiple times...once for each record in your query table. This is why we have the "DBQ Current Record Index" input variable. It tells you which record it is currently calculating for. That means a set out output results are collected internally for each record. Results for the winning record get used.

Please call me. I really do want to see you have success with this block.

Anthony

velcro
Posts:31
Joined:Thu Apr 15, 2010 8:49 am
First Name:Steve
Last Name:Cohen

Re: Using Query Equation(I)

Post by velcro » Mon Apr 20, 2020 1:46 pm

Anthony,

Sorry I did not reply sooner. I ended up just brute-forcing it and looping through the records. When I have more time, I will revisit this and we can talk about how I could apply the Query equation to what I am trying to do.

Thanks,

Steve

Post Reply