how can I tell if no records were found?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

how can I tell if no records were found?

Post by tkilshaw »

When I do a FIND how can I tell if no records were found?

Please give a code fragment.

Also how can I find some records, tell how many were found then take the Nth record?

thanks,

Terry
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

Post by tkilshaw »

I guess that you need to use COUNT with a qualifying expression?

That leads to a lot of redundant processing. I need to COUNT and FIND or FIND and COUNT. Either way I end up iterating twice through all objects of the target type.

Is there not a concept of a found set in Aware?

It looks like when I find, all found objects are put in the context, presumable with their sort order intact. If there was a way to reference the found set I would not need to do things twice.

This could get very expensive as record counts grow.

Terry
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

Terry,

> When I do a FIND how can I tell if no records were found?
You can use EXISTS in a condition before you run your query:

If NOT (EXISTS ...) Then ...

where the expression for EXISTS is exactly the same as for FIND in the query.

> ... tell how many were found ...
You can use COUNT to determine how many records would be found by FIND. The expression for COUNT must be exactly the same as for FIND.

> … then take the Nth record?
Please give me an example of what you would like to do with the Nth record but not with the others. Generally, if you run a query and then do some action with the results, the system will automatically iterate through the result set and execute the action for each record in the set.

You can also limit the number of records returned by a query by appending TAKE BEST N to the query. This is useful in situations like finding the youngest child of a person, etc:

FIND Child WHERE Clild.Parent = Person ORDER BY Clild.DateOfBirth DESC TAKE BEST 1

> Is there not a concept of a found set in Aware?
Not at the moment, although we will consider it in the future. So far the performance of aggregate database operations was not an issue in existing Aware IM applications that we know of (with up to hundreds of thousands of database records in some), nor was it reported to us by users working with any of the Aware IM - supported databases.
Aware IM Support Team
Post Reply