Hi Lee,
1) I think we're talking about two different things. If you open the Method Editor, create a new method, scroll down to the "Database Manager" node, then right-click on "getTable" and choose "Move Sample". You'll see this code:
- Code: Select all
//get a specific table and get column info
var jstable = databaseManager.getTable('user_data','orders');
var tableSQLName = jstable.getSQLName();
var columnNamesArray = jstable.getColumnNames();
var firstColumnName = columnNamesArray[0];
var jscolumn = jstable.getColumn(firstColumnName);
var columnLength = jscolumn.getLength();
var columnType = jscolumn.getType();
var columnSQLName = jscolumn.getSQLName();
2) Regarding views - you can issue your own SQL statements against views, you can execute stored procedures against views - you just can't BASE A FORM on a view. Try this: go to File -> New Form. You'll see a list of server connections (top popup menu). When you choose one (choose "example_data") - you'll see a list of all the TABLES in that database (NOT views).
3) Regarding globals - these are simply in-memory variables. You can assign them ANY value - coming from a database, view, table, or constant value. To execute your own query, open the Method Editor, create a new method, scroll down to the "Database Manager" node, then right-click on "getDataSetByQuery" and choose "Move Sample". You'll see this code:
- Code: Select all
//Get a dataset based on query
var maxReturedRows = 10;//useful to limit number of rows
var query = 'select c1,c2,c3 from test_table';//do not use '.' or special chars in names or aliases if you want to access data by name
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, maxReturedRows);
//place in label: elements.myLabel.text = '<html>'+dataset.getAsHTML()+'</html>';
//example to calc a strange total
global_total = 0;
for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
dataset.rowIndex = i;
global_total = global_total + dataset.c1 + dataset[3];
}
//example to assign to dataprovider
//employee_salary = dataset.getValue(row,column)
Hope this helps,
Bob Cusick