[odb-users] how to get the result size of oracle query

Boris Kolpackov boris at codesynthesis.com
Thu Sep 27 05:20:23 EDT 2012


Hi Scott,

Scott Zhang <macromarship at gmail.com> writes:

>    I am trying to query from oracle. Then I tried to use result.size() to
> get the total number. Unfortunately, it raises "result_not_cached". Then I
> tried to call "cache" manually but still get such exception.
>    I have to look into the libodb-oracle code. And see the cache and size
> function is actually not implemented.

Query result caching is not supported for Oracle, as discussed in Section
16.5.2, "Query Result Caching" in the ODB manual.


> So how do you get the count of rows?

Oracle streams query results so the result size is not known. You can
either iterate until the end of the result set (potentially saving the
loaded items) counting the entries. Or, you can run SELECT COUNT(*);
the Views chapter has an example of this.

Note also that both of these approaches have drawbacks. In fact, the
best solution is to re-design your application not to need the result
size in the first place. This is also what's recommended by Oracle.

Boris



More information about the odb-users mailing list