If a stored procedure is known to return at least one result set, procedure queries can be executed just like normal select queries. Of course in addition to returning data, such procedures can perform any other database operations.

Below is an example of creating a ProcedureQuery, initializing its parameters, and processing execution results.

    DataContext ctxt;

    // "my_procedure" is a name of a stored procedure,
    // that must exist in the DataMap
    ProcedureQuery query = new ProcedureQuery("my_procedure", Artist.class);

    // Set "IN" parameter values
    query.addParam("paramter1", "abc");
    query.addParam("parameter2", new Integer(3000));

    // run query as a normal select query
    List objects = ctxt.performQuery(query);

    // process results
    Iterator it = objects.iterator();
    while(it.hasNext()) {
      Artist artist = (Artist) it.next();
      ....
    }