Problem

How to manipulate table data by code (client side)


Solution

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 manipulate data in a table on the client side which is not the best choice, but the best way is use server-side code:

// Get an active table object
dataweb.client.Table tbl=client.openTable(session, "<Package>.<Table>");

// Move cursor to required record
tbl.seek("<Index Name>",new Object[]{<Index parameter1>[,<Index parameter2>]})

// We want to edit some data
tbl.edit();
tbl.setValue("<Column Name>",<Value>);
tbl.update();

// Create new record
tbl.addNew();
tbl.setValue("<Column Name>",<Value>);
....
....
tbl.setValue("<Column Name>",<Value>);
tbl.update();

// Close table object
tbl.close();

Published in Fri, 10 December 2010 16:15