Using Database Operations

The Update Operation

ProcedureTo Perform an Update Operation on a Table

  1. Execute the update() method.


    Note –

    The content of the input.getText() file may contain null, meaning it will not have a “where” clause or it can contain a “where” clause such as empno > 50.


  2. Using a while loop together with next(), move to the row that you want to update.

  3. Assign updating value(s) to the fields of the table OTD

  4. Update the row by calling updateRow().


    package prjDB2_JCDjcdALL;
    
    
    public class jcdUpdate
    {
    
    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, 
    otdDB2.OtdDB2OTD otdDB2_1, com.stc.connector.appconn.file.FileApplication 
    FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Updating the Rate and Last_update fields .. " );
            FileClient_1.write();
            otdDB2_1.getDb_employee().update( input.getText() );
            while (otdDB2_1.getDb_employee().next()) {
            otdDB2_1.getDb_employee().setLAST_NAME( "Krishna" );
            otdDB2_1.getDb_employee().setFIRST_NAME( "Kishore" );
            otdDB2_1.getDb_employee().updateRow();
            }
            FileClient_1.setText( "Update Done." );
            FileClient_1.write();
        }
    
    }