Chapter 6
Section 6.2
Using VSAM Operations
VSAM eWay Database Operations (JCD)
VSAM eWay Adapter User’s Guide
59
Sun Microsytems, Inc.
public com.stc.codegen.logger.Logger logger;
public com.stc.codegen.alerter.Alerter alerter;
public com.stc.codegen.util.CollaborationContext collabContext;
public com.stc.codegen.util.TypeConverter typeConverter;
public void receive(
com.stc.connector.appconn.file.FileTextMessage input,
otdVSAM.OtdVSAMOTD otdVSAM_1, dtd.otdOutputDTD_1935483687.Emp
otdOutputDTD_Emp_1, com.stc.connector.appconn.file.FileApplication
FileClient_1 )
throws Throwable
{
FileClient_1.setText( "Delete record .." );
FileClient_1.write();
otdVSAM_1.getCICSEMP().delete( input.getText() );
FileClient_1.setText( "Done delete." );
FileClient_1.write();
}
}
6.2.2
Prepared Statement
A Prepared Statement OTD represents a SQL statement that has been compiled. Fields
in the OTD correspond to the input values that users need to provide.
Prepared statements can be used to perform insert, update, delete and query
operations. A prepared statement uses a question mark (?) as a place holder for input.
For example:
insert into EMP_TAB(Age, Name, Dept No) value(?, ?, ?)
To execute a prepared statement, set the input parameters and call
executeUpdate()
and
specify the input values if any.
getPrepStatement().getPreparedStatementTest().setAge(23);
getPrepStatement().getPreparedStatementTest().setName(‘Peter Pan’);
getPrepStatement().getPreparedStatementTest().setDeptNo(6);
getPrepStatement().getPreparedStatementTest().executeUpdate();
6.2.3
Batch Operations
To achieve better performance, consider using a bulk insert if you have to insert many
records. This is the “Add Batch” capability. The only modification required is to include
the
addBatch()
method for each SQL operation and then the
executeBatch()
call to
submit the batch to the database server. Batch operations apply only to Prepared
Statements.
getPrepStatement().getPreparedStatementTest().setAge(23);
getPrepStatement().getPreparedStatementTest().setName(‘Peter Pan’);
getPrepStatement().getPreparedStatementTest().setDeptNo(6);
getPrepStatement().getPreparedStatementTest().addBatch();
getPrepStatement().getPreparedStatementTest().setAge(45);
getPrepStatement().getPreparedStatementTest().setName(‘Harrison
Ford’);
getPrepStatement().getPreparedStatementTest().setDeptNo(7);