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 prjSybase_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, otdSybase.OtdSybaseOTD otdSybase_1,
     com.stc.connector.appconn.file.FileApplication FileClient_1 )
            throws Throwable
        {
            FileClient_1.setText( "Selecting records from db_employee
     table via Table Select........" );
            FileClient_1.write();
            otdSybase_1.getDb_employee().select( input.getText() );
            while (otdSybase_1.getDb_employee().
    next()) {
                otdOutputDTD_DB_Employee_1.setEmpNo( typeConverter.
    shortToString( otdSybase_1.getDb_employee().getEMP_NO(), "#",
     false, "" ) );
                otdOutputDTD_DB_Employee_1.setLastname(
     otdSybase_1.getDb_employee().getLAST_NAME() );
                otdOutputDTD_DB_Employee_1.setFirstname(
     otdSybase_1.getDb_employee().getFIRST_NAME() );
                otdOutputDTD_DB_Employee_1.setRate(
     otdSybase_1.getDb_employee().getRATE().toString() );
                otdOutputDTD_DB_Employee_1.setLastDate(
     typeConverter.dateToString( otdSybase_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();
        }
    
    }