Toad World® Forums

Checking Mutiple values in collection without index


#1

As per the unit testcase, we need to check mutiple records in( say more than 3 records in) collection of procedural outcome & expected outcome.

While executing testcase ,Programmatic outcome would be different, as we don’t have any order by class in procedure (Selected Query). i.e, Consolidated output in procedural outcome & expected outcome would be same, if we match by index the it would be differ.

Is it any possibility to match the this condition using CT without using Order by class in procedure?

Thanks in Advance.

Regards,
Bala


#2

If I understand you correctly, you want to check the contents of a collection, but the order of the data in the collection is not always the same, since it is populated by a query without an order by.

When you specify a collection comparison, you can specify that indexes do not need to match, but the test code still compares the contents of the actual and expected collections in the same order.

The only way to achieve non-ordered comparisons is to compare SQL datasets: tables and queries.

So I believe the only way you can achieve what you want in our product today is to move the contents of the collection to a query using the table operator (you can do this only for nested tables and varrays) and then compare queries, as in:

SELECT * FROM TABLE (my_collection)

The collection type has to be defined at the schema level for this to work.

I hope this helps.

SF


#3

Your understanding is correct.

Unfortunately all my collectin objects are associate array. So we will use order by clause in the code to resolve this issue.

It would be better, if we add this feature in future release.

Regards,
Bala