Using Database Operations

The Query (Select) Operation

ProcedureTo perform a query operation on a table

  1. Execute the select() method with the “where” clause specified if necessary.

  2. Loop through the ResultSet using the next() method.

  3. Process the return record within a while() loop.

    For example:


    package prjSQLServer_JCDjcdALL;
    
    
    public class jcdTableSelect
    {
    
        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, dtd.otdOutputDTD1325973702.
    DB_Employee otdOutputDTD_DB_Employee_1, otdSQLServer.OtdSQLServerOTD
    otdSQLServer_1, com.stc.connector.appconn.file.FileApplication FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Selectiong records from db_employee table via
    Table Select........" );
            FileClient_1.write();
            otdSQLServer_1.getDb_employee().select( input.getText() );
            while (otdSQLServer_1.getDb_employee().next()) {
                otdOutputDTD_DB_Employee_1.setEmpNo( typeConverter.shortToString(
    otdSQLServer_1.getDb_employee().getEMP_NO(), "#", false, "" ) );
                otdOutputDTD_DB_Employee_1.setLastname(
    otdSQLServer_1.getDb_employee().getLAST_NAME() );
                otdOutputDTD_DB_Employee_1.setFirstname(
    otdSQLServer_1.getDb_employee().getFIRST_NAME() );
                otdOutputDTD_DB_Employee_1.setRate(
    otdSQLServer_1.getDb_employee().getRATE().toString() );
                otdOutputDTD_DB_Employee_1.setLastDate(
    typeConverter.dateToString( otdSQLServer_1.getDb_employee().getLAST_UPDATE(),
    "yyyy-MM-dd hh:mm:ss", false, "" ) );
                FileClient_1.setText( otdOutputDTD_DB_Employee_1.marshalToString() );
                FileClient_1.write();
            }
            FileClient_1.setText( "Table Select Done." );
            FileClient_1.write();
        }
    
    }