Examples of DBCmdParam


Examples of org.apache.empire.db.DBCmdParam

        // Define shortcuts for tables used - not necessary but convenient
        CompanyDB.Departments DEP = db.DEPARTMENT;
        // Define the query
        DBCommand cmd = db.createCommand();
        // Create parameters
        DBCmdParam empIdParam  = cmd.addParam(null);
        // the previous line could be shorter
        // DBCommandParam empIdParam  = cmd.addCmdParam(id);
        // create statement
        cmd.select(DEP.getColumns());
        cmd.where(DEP.ID.is(empIdParam));
        // set param value
        empIdParam.setValue(id);
        // check command
        assertNotNull(cmd.getParamValues());
        assertTrue(cmd.getSelect().indexOf('?') > 0);

        DBReader r = new DBReader();
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

    private static void commandParamsSample(Connection conn, int idProdDep, int idDevDep)
    {
        // create a command
        DBCommand cmd = db.createCommand();
        // Create cmd parameters
        DBCmdParam curDepParam = cmd.addParam(); // Current Department
        DBCmdParam genderParam = cmd.addParam(); // Gender ('M' or 'F')
        // Define the query
        cmd.select(T_EMP.C_FULLNAME);
        cmd.join  (T_EMP.C_EMPLOYEE_ID, db.V_EMPLOYEE_INFO.C_EMPLOYEE_ID);
        cmd.where (T_EMP.C_GENDER.is(genderParam));
        cmd.where (db.V_EMPLOYEE_INFO.C_CURRENT_DEP_ID.is(curDepParam));

        System.out.println("Perfoming two queries using a the same command with different parameter values.");
       
        DBReader r = new DBReader();
        try {
            // Query all females currently working in the Production department
            System.out.println("1. Query all females currently working in the production department");
            // Set command parameter values
            genderParam.setValue('F'); // set gender to female
            curDepParam.setValue(idProdDep); // set department id to production department
            // Open reader using a prepared statement (due to command parameters!)
            r.open(cmd, conn);
            // print all results
            System.out.println("Females working in the production department are:");
            while (r.moveNext())
                System.out.println("    " + r.getString(T_EMP.C_FULLNAME));
            r.close();  

            // Second query
            // Now query all males currently working in the development department
            System.out.println("2. Query all males currently working in the development department");
            // Set command parameter values
            genderParam.setValue('M'); // set gender to female
            curDepParam.setValue(idDevDep); // set department id to production department
            // Open reader using a prepared statement (due to command parameters!)
            r.open(cmd, conn);
            // print all results
            System.out.println("Males currently working in the development department are:");
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

    private static void commandParamsSample(Connection conn, int idProdDep, int idDevDep)
    {
        // create a command
        DBCommand cmd = db.createCommand();
        // Create cmd parameters
        DBCmdParam curDepParam = cmd.addParam(); // Current Department
        DBCmdParam genderParam = cmd.addParam(); // Gender ('M' or 'F')
        // Define the query
        cmd.select(T_EMP.C_FULLNAME);
        cmd.join  (T_EMP.C_EMPLOYEE_ID, db.V_EMPLOYEE_INFO.C_EMPLOYEE_ID);
        cmd.where (T_EMP.C_GENDER.is(genderParam));
        cmd.where (db.V_EMPLOYEE_INFO.C_CURRENT_DEP_ID.is(curDepParam));

        System.out.println("Perfoming two queries using a the same command with different parameter values.");
       
        DBReader r = new DBReader();
        try {
            // Query all females currently working in the Production department
            System.out.println("1. Query all females currently working in the production department");
            // Set command parameter values
            genderParam.setValue('F'); // set gender to female
            curDepParam.setValue(idProdDep); // set department id to production department
            // Open reader using a prepared statement (due to command parameters!)
            r.open(cmd, conn);
            // print all results
            System.out.println("Females working in the production department are:");
            while (r.moveNext())
                System.out.println("    " + r.getString(T_EMP.C_FULLNAME));
            r.close();  

            // Second query
            // Now query all males currently working in the development department
            System.out.println("2. Query all males currently working in the development department");
            // Set command parameter values
            genderParam.setValue('M'); // set gender to female
            curDepParam.setValue(idDevDep); // set department id to production department
            // Open reader using a prepared statement (due to command parameters!)
            r.open(cmd, conn);
            // print all results
            System.out.println("Males currently working in the development department are:");
View Full Code Here

Examples of org.apache.empire.db.DBCmdParam

                    if (col!=null && col.getRowSet() == table)
                    {  // add the constraint
                      if (cmpExpr.getValue() instanceof DBCmdParam)
                      {  // Create a new command param
                        DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                        DBCmdParam param =(DBCmdParam)cmpExpr.getValue();
                        DBCmdParam value = upd.addParam(colExpr, param.getValue());
                        cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                      }
                        upd.where(cmp);
                    }   
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.