Using Database Operations

ProcedureTo perform an insert operation on a table

  1. Execute the insert() method. Assign a field.

  2. Insert the row by calling insertRow()

    This example inserts an employee record.


    package prjOracle_JCDjcdALL;
    
    
    public class jcdInsert
    {
    
        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,
     otdOracle.OtdOracleOTD otdOracle_1,     dtd.otdInputDTD_1206505729.DB_Employee
     otdInputDTD_DB_Employee_1, com.stc.connector.appconn.file.FileApplication
    FileClient_1 ) throws Throwable
        {
            FileClient_1.setText( "Inserting records in to db_employee table......" );
            FileClient_1.write();
            otdInputDTD_DB_Employee_1.unmarshalFromString( input.getText() );
            otdOracle_1.getDb_employee().insert();
            for (int i1 = 0; i1 < otdInputDTD_DB_Employee_1.countX_sequence_A(); i1 += 1) {
                otdOracle_1.getDb_employee().setEMP_NO( typeConverter.stringToShort(
     otdInputDTD_DB_Employee_1.getX_sequence_A( i1 ).getEmpNo(), "#", false, 0 ) );
                otdOracle_1.getDb_employee().setLAST_NAME( otdInputDTD_DB_Employee_1.
    getX_sequence_A( i1 ).getLastname() );
                otdOracle_1.getDb_employee().setFIRST_NAME( otdInputDTD_DB_Employee_1.
    getX_sequence_A( i1 ).getFirstname() );
                otdOracle_1.getDb_employee().setRATE( new java.math.BigDecimal(
     otdInputDTD_DB_Employee_1.getX_sequence_A( i1 ).getRate() ) );
                otdOracle_1.getDb_employee().setLAST_UPDATE( typeConverter.
    stringToTimestamp( otdInputDTD_DB_Employee_1.getX_sequence_A( i1 ).getLastDate(),
     "yyyy-MM-dd hh:mm:ss", false, "" ) );
                otdOracle_1.getDb_employee().insertRow();
            }
            FileClient_1.setText( "Insert Done." );
            FileClient_1.write();
        }
    
    }