How to read view by code (server side)


Dataweb project is based on a RDBMS (HSQLDB or Postgres) but usually you don't use SQL, but the specific classes. The following code shows how to open data of a view on the client side which is the better choice than the client side, because the classes are most efficient:

// Get an active view object
dataweb.datastore.View view=dbSession.openView("<Package>.<View>");

// Apply filter and order
view.applyFilter("<Condition>", "<Order>")

// We want read data
for (int i=0;i<=view.getRowCount()-1;i++){
   val1 = view.getValue(i, "<Column Name>");
   valn = view.getValue(i, "<Column Name>");

// Close view object

Published in Fri, 10 December 2010 16:16