| How can I access the result of a Database element's query? |
| Categories: Audium OpenSDK, Audium Studio (3.4.x) |
| Article ID: | 99 |
| Last updated: | January 08, 2007 |
| User Opinions |
|
No users have voted.
|
|
Thank you for rating this answer.
|
SUMMARY
This article explains how to access the result of a query that was executed by a Database element.
SYMPTOMS
Developer has configured a Database element as part of an Audium application, but is not sure how to access the result of the query once it is executed.
RESOLUTION
Database elements have a "Type" setting, which allows the developer to specify whether the result of the query will always be a single row (choose "single") or multiple rows (choose "multiple"). The result of the query will be stored in different ways, depending on the value of this setting.
If Type is set to single
Element data is created when the "Type" setting is set to "single". Element data given the names of the return columns are created containing the respective return values. For example, if a query returned the following information:
foo bar 123 456
then the following element data will be created: "foo" with the value "123" and "bar" with the value "456". This element data can be accessed in all of the standard ways element data can be accessed (e.g. substitution, etc.).
If Type is set to multiple
Session data is created when the "Type" setting is set to "multiple". Since the result may contain many rows, there is no easy way to store it as element data, and so a Java object is stored in the session instead. This object is of type ResultSetList. The name of the variable that references this object is specified by the developer in the "Session Data Key" setting. This object will always be created, even if the query produced no results; in that case, the ResultSetList object will be empty.
Note that this object must be accessed via Java. However, the Audium Java API provides methods to operate on this object, such as getNumRows() to return the number of rows stored in the object.
|
| Visitor Comments |
|
No visitor comments posted. Post a comment
|
| Related Questions |
|
No related questions were found.
|
| Attachments |
|
No attachments were found.
|