Similar to Caché so also in **IRIS**, you have ClassQueries available in 2 variants
* [Basic class queries](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GOBJ_queries#GOBJ_queries_basics), which use the class %SQLQuery and an SQL SELECT statement.
* [Custom class queries](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GOBJ_queries#GOBJ_queries_userqueries), which use the class %Query and custom logic to execute, fetch, and close the query.
The [related documentation](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GOBJ_queries#GOBJ_queries_intro) is excellent and very detailed.
You will see a bunch of examples of how to use it with [%ResultSet](http://localhost:52773/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Library.ResultSet "Class") or %SQL.Statement
Following the suggestions, you will add the keyword [[SqlProc]](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=ROBJ_query_sqlproc) to make it visible in SMP or over JDBC/ODBC
![](/sites/default/files/inline/images/images/image(1508).png)
**Attention:** [SqlProc] Doesn't distinguish whether your procedure returns a scalar value (acting as StoredFunction)
or if it returns a ResultSet. You have to check the definition to see the difference.
Returning a ResultSet means that you can use this StoredProcedure not only by a CALL statement
but also like any Sql Table applying WHERE, GROUP, ORDER, JOIN, .. whatever is available to a SELECT
This fact is not new but never mentioned in any documentation I know of.
Examples:
SELECT TOP 5 * FROM SYS.Process_JOBEXAM() ORDER BY Commands DESC
![](/sites/default/files/inline/images/images/image(1509).png)
SELECT Name,Directory,MountRequired FROM Config.Databases_List() order by Name
![](/sites/default/files/inline/images/images/image(1510).png)
**My suggestion:**
Understand a Stored Procedure returning a ResultSet as kind of a Sub-Select (with additional parameters).