UpdateData.java

    The following sample code is for updating data in a table.

    In this example Product Category and Product columns in "Sales" table are updated for data matching the criteria

    ("Region" = 'West') and ("Product Category" = 'Stationary')

    Before trying it out

    public class UpdateData
    {

    publicstatic void updateData()
    throws Exception
    {
    ReportClient rc = Config.getReportClient();

    rc.login(Config.LOGINNAME,Config.PASSWORD);

    String uri = rc.getURI(Config.LOGINNAME,Config.DATABASENAME,"Sales");

    rc.updateData(uri,getValuesToUpdate(),getCriteria(),null);
    rc.logout();

    }

    privatestatic HashMap getValuesToUpdate()
    {
    SimpleDateFormat dtFmt = newSimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    HashMap rowValsMap = newHashMap();
    rowValsMap.put("Product Category","Sample_Grain");
    rowValsMap.put("Product","Sample_Wheat");
    return rowValsMap;
    }

    privatestatic String getCriteria()
    {
    return "(\"Region\" = 'East') and (\"Product Category\" = 'Grocery')";
    }

    publicstatic void main(String[] args)
    throws Exception
    {
    updateData();
    }
    }

     

    Copyright © 2016, ZOHO Corp. All Rights Reserved.