Insert Rows

You can insert a new row of data or a record in a table in the Data Store by referring to the table’s unique ID or name. You can also insert multiple rows in a table as explained in the next section.

Note:
  1. The table and the columns in it must already be created. You can create a table and the columns for it from the console.

  2. You will be able to insert upto 5000 records in each table per project in the development environment. You can create upto 25,000 records overall in each project in the development environment. There are no upper limits for record creation in the production environment.

Insert a Single Row

You must create a row instance and then pass the column names and their corresponding values as shown in the sample code below. The insertRow() method inserts a row to the table whose instance you create by referring to its unique name or ID. A unique RowID value for the row is automatically generated once a row is inserted.

Ensure the following packages are imported:

    
copy
import com.zc.component.object.ZCObject; import com.zc.component.object.ZCRowObject; import com.zc.component.object.ZCTable;
    
copy
//Create a base Object Instance ZCObject object = ZCObject.getInstance(); //Get a Table Instance referring the tableID on base object ZCTable tab = object.getTable("1510000000110121"); //Create a row instance ZCRowObject row = ZCRowObject.getInstance(); //Set the required column values using set() method on the row instance row.set("Name","George Smith"); row.set("Age", 25); //Add the single row to table by calling insertRow() method tab.insertRow(row);

Insert Multiple rows

You can insert multiple rows in a table by constructing a list of row objects and passing it as an argument to the insertRows() method as shown below.

Ensure the following packages are imported:

    
copy
import com.zc.component.object.ZCObject; import com.zc.component.object.ZCRowObject; import com.zc.component.object.ZCTable;
    
copy
//Create a List of RowObjects List rows = new ArrayList(); //Create a base Object Instance ZCObject object = ZCObject.getInstance(); //Get a Table Instance referring the tableID on base object ZCTable tab = object.getTable(1510000000110121L); //Create required number of row instances ZCRowObject row1 = ZCRowObject.getInstance(); ZCRowObject row2 = ZCRowObject.getInstance(); //Set the column values on the respective rows using set() method row1.set("Name","George Smith"); row1.set("Age", 25); row2.set("Name","Moana Violet"); row2.set("Age", 22); //Add rows to List using add() method rows.add(row1); rows.add(row2); //Add the list to table using insertRows() method tab.insertRows(rows);

Last Updated 2023-09-03 01:06:41 +0530 +0530