When updating a relational database you must use the SQLUpdate activity object. You can pass in parameters or pull the the update data from another location (see this following page on Asynchronous Delivery).
String sql_insert = "insert into littleblackbook values (10010,'Jimbo Goggins','Buckingham Palace','0123456789')"; SQLUpdate update = new SQLUpdate( sql_insert );
service.perform(update);
String sql_update = "update littleblackbook set address = '13 Cod Road' where id = 10010"; String sql_delete = "delete from littleblackbook where id = 10010";
String sql = "update littleblackbook set address = ? where id = ?"; SQLUpdate update = new SQLUpdate( sql ); update.setParameter(1, "35 Coronation Street, Manchester"); update.setParameter(2, "10010");
create table mytable (id INTEGER, name VARCHAR(64), address VARCHAR(128), phone VARCHAR(20))Use this SQL statement to create a new table. You can drop the table like this:
drop table mytable
See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/SQLUpdateExample.java for an example solution.
You can bulk load data from one table to another using the SQLBulkLoad activity object. It is important that the target table has the same schema as the source table.
SQLQuery query = new SQLQuery("select * from littleblackbook where name like '%Krause'");and connect its output to a WebRowSet activity:
WebRowSet rowset = new WebRowSet( query.getOutput() );
SQLBulkLoad bulkLoad = new SQLBulkLoad( rowset.getOutput(), tableName );
bulkLoad.setTransactionally(true);It is switched off by default.
ActivityRequest request = new ActivityRequest(); request.add( query ); request.add( rowset ); request.add( bulkLoad ); service.perform( request );
See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/SQLBulkLoadExample.java for an example solution.
Updates to an XML database are made using the XUpdate language. In this example, you will modify entry no. 99 and change the value within the name element.
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate"> <xu:update select="/entry[@id=99]/name"> Harold Bishop </xu:update> </xu:modifications>
XUpdate update = new XUpdate( xupdate_statement );
See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/XUpdateExample.java for an example solution.
Back: Processing Results | Up: Using the Client Toolkit | Next: Control Flow |
© International Business Machines Corporation, 2002-2006 | © The University of Edinburgh, 2002-2006 |