1 grid.result.isEmpty
Release 2017.3
Tag available since version 2017.3.
Returns a boolean to indicate if a query on grid returns no data.
<grid.result.isEmpty>
<resultSet /> !
</grid.result.isEmpty>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
EresultSet | ResultSet | The result set obtained from select.grid. |
Returns | |
---|---|
Type | Description |
boolean | Returns if the grid is empty (true) or contain data (false). |
It is necessary to check if the grid has data before starts to do forward on the result set. If you try to show data from an empty grid an exception ocurs
Copy
XSQLScriptException[java.sql.SQLException: resultset is closed.]
Example
Copy
<xsql-script> <body> <connection name='sysmaster1'> <set name='rs'> <!-- Run a multi database query, returning a memory result set. --> <!-- Each db has it's pool configuration timeout but can be owerride via timeout !=0 --> <select.grid name='grid_demo' timeout='30'> <columns>tabname, nrows, npused</columns> <from table='systables' /> <where>tabname LIKE 'capuntes%'</where> </select.grid> </set> </connection> <if> <expr><grid.result.isEmpty><rs/></grid.result.isEmpty></expr> <then> <println>... The grid is empty.</println> </then> <else> <println>... The grid contains data:</println> <println> <rs/> </println> </else> </if> </body> </xsql-script>
... The grid contains data:
+--------+-----------+----------+--------------+----------+
|tabname |nrows |npused |grid_node |grid_error|
|varchar |float |float |char |char |
|visible |visible |visible |visible |visible |
+--------+-----------+----------+--------------+----------+
|capuntes| 7887,000| 1604,000|demo_sports | |
|capuntes| 442028,000| 89265,000|demo_industria| |
|capuntes|4557441,000|955229,000|demo_cons | |
+--------+-----------+----------+--------------+----------+
Example
Copy
<xsql-script> <body> <connection name='sysmaster1'> <set name='rs'> <!-- Run a multi database query, returning a memory result set. --> <!-- Each db has it's pool configuration timeout but can be owerride via timeout !=0 --> <select.grid name='grid_demo' timeout='30'> <columns>tabname, nrows, npused</columns> <from table='non_existent_table' /> <where>tabname LIKE 'capuntes%'</where> </select.grid> </set> </connection> <if> <expr><grid.result.isEmpty><rs/></grid.result.isEmpty></expr> <then> <println>... The grid is empty.</println> </then> <else> <println>... The grid contains data:</println> <println> <rs/> </println> </else> </if> </body> </xsql-script>
... The grid is empty.