DatabaseServices.executeSelectStatement

Executes a SQL select statement and passes each returned row to the specified callback function. The callback function should be specified with a single argument representing an object containing a key/value pair for each column in the row, see examples. Returns the number of rows that have been passed to the callback function.

The callback function should return true to continue execution or false to terminate execution. If the return is omitted, execution continues.

Example 1: load Ebase table

 var count = services.database.executeSelectStatement(
   "SAMPLES", 
   "select cat_name, cat_value, creation_date from categories", 
   function (columnData)
   {
     tables.categories.insertRow();
     tables.categories.categoryName.value = columnData.cat_name;
     tables.categories.categoryValue.value = columnData.cat_value;
     tables.categories.creationDate.value = columnData.creation_date;
     return true;      // continue
   });
 
Example 2: load Ebase table - the table contains columns with the same names as the columns returned by the SQL statement. Note that this technique cannot be used with columns of type Date, Time or DateTime.
 var rowData = [];
 var tableData = {rows: rowData};
 services.database.executeSelectStatement("SAMPLES", "select * from tablexyz",
   function (columnData)
   {
     rowData.push(columnData);
     return true;
   });
 // load the table
 tables.sampleTable.loadFromJSON(JSON.stringify(tableData));
 // scroll to display the first row
 tables.sampleTable.control.scrollToTop();
 

returns int

Parameters

java.lang.String  databaseConnectionName,  java.lang.String  selectStatement,  SelectStatementCallback callbackFunction,