how to build a database events query?

Hello,

I have a working app that allows the user to graphically make selection that I would like to translate into a Database Events query. If I were using SQL, I would just concatenate various strings together and have my query. SInce Database Events is based on the object model, I don’t see how I can create a dynamic query. I realize that I can put variables into the query, but in some case whole phrases mayor may not be needed.

For example:

User can select value for field 1, or all values
User can select value for field 2, or all values

This comes out to 4 possibilities. The possibilities grow exponentially as I add more fields.

So, is there any way I can execute a query against a Database events database, then execute a query agaist the results to refine them? Alternatively, is there a way to build a query dynamically? I tried building the query as a text string then using “run script”, but it didn’t work.

Your help is appreciated,

Allan

I don’t use database events any more because I found it unreliable and slow when compared to using a sqlite database. If you want to use database events here’s a resource I used when learning it. It has a section on how to find records in your database. Maybe it will help you…
http://www.mactech.com/articles/mactech/Vol.22/22.02/IntrotoDatabaseEvents/index.html

One choice would be to perform your first query then set those results to a variable in your code. Then you can search only that variable to further refine your results.

I hope that helps. FYI: post #9 in this thread has handlers for using a sqlite database with applescript.
http://bbs.macscripter.net/viewtopic.php?id=27928