You can add rows to the table using the following line commands.
Any rows added by these functions are indicated by an I under the F heading.
Assume that an order must be added for the customer Reely Great Videos. To add a new row, type the I line command in Cmd for any displayed row, and then press Enter to insert a new data entry line after the selected row. The new row will include an I at the beginning of the row to indicate the line was newly inserted. In the following example, the I was entered on the last row (ORDER_ID 1305), so a new row was added after that row. Notice that the appropriate value for the foreign key column entry was automatically inserted, which in this instance was CUST_ID 07160.
Figure: Adding a Row to the ORDERS Table
-------------------------------- Optim: Edit ----------------------------------
COMMAND ===> SCROLL ===> PAGE
Cmd F == Table: FOPDEMO.CUSTOMERS(T1) ===================== 10 OF 20 === MORE>>
CUST_ID CUSTNAME ADDRESS CITY STATE
------- -------------------- ==================== --------------- -----
___ U 07160 Reely Great Videos 590 Frontage Rd Boston MA
Cmd F == Table: FOPDEMO.ORDERS(T2) ========================== 1 OF 4 === MORE>>
ORDER_ID CUST_ID ORDER_DATE ORDER_TIME FREIGHT_CHARGES ORDER_SALESMAN
-------- ------- ---------- ---------- --------------- --------------
*** *********************************** TOP ***********************************
___ 1522 07160 04/12/1999 09.27.51 12.00 RP0013
___ 1491 07160 03/29/1999 16.24.41 9.25 RP0013
___ 1305 07160 03/15/1999 10.23.38 12.95 RP0013
... I 07160
*** ********************************* BOTTOM **********************************
Type the order information and press Enter. Based on user options for default column values, Access will either insert default values for any columns you leave blank or prompt you for the columns requiring input, as defined to DB2. The default values are based on the data type of the column and DB2-defined values, if provided. The possible values are: spaces, zeros, current date, current time, and NULL. For example, if a value is not entered for ORDER_DATE, a date column, the current date is automatically inserted.
The I status flag is displayed for the inserted row.
Figure: Row Inserted in the ORDERS Table
-------------------------------- Optim: Edit ----------------------------------
COMMAND ===> SCROLL ===> PAGE
Cmd F == Table: FOPDEMO.CUSTOMERS(T1) ===================== 10 OF 20 === MORE>>
CUST_ID CUSTNAME ADDRESS CITY STATE
------- -------------------- ==================== --------------- -----
___ U 07160 Reely Great Videos 590 Frontage Rd Boston MA
Cmd F == Table: FOPDEMO.ORDERS(T2) ========================== 1 OF 4 === MORE>>
ORDER_ID CUST_ID ORDER_DATE ORDER_TIME FREIGHT_CHARGES ORDER_SALESMAN
-------- ------- ---------- ---------- --------------- --------------
*** *********************************** TOP ***********************************
___ 1522 07160 04/12/1999 09.27.51 12.00 RP0013
___ 1491 07160 03/29/1999 16.24.41 9.25 RP0013
___ 1305 07160 03/15/1999 10.23.38 12.95 RP0013
___ I 1603 07160 07/10/1999 11.04.30 8.75 RP0013
*** ********************************* BOTTOM **********************************
The Copy line commands (C and CC), the Repeat line commands (R and RR), and the Repeat Pending line commands (RP and RRP), can also be used to insert rows.
The Repeat and Repeat Pending line commands both duplicate rows to be inserted into the table. However, use the Repeat Pending line commands to repeat rows with partitioned indexes. This allows you to edit the repeated rows before Access attempts to insert them into the database.
To minimize data entry when creating a new order, use the Repeat line command on a row in the ORDERS window. The ORDERS row is repeated once after itself, but an error condition results. This is indicated by an E under the F heading as shown in the following figure.
Figure: Error Condition
-------------------------------- Optim: Edit ----------------------------------
COMMAND ===> SCROLL ===> PAGE
Cmd F == Table: FOPDEMO.CUSTOMERS(T1) ===================== 10 OF 20 === MORE>>
CUST_ID CUSTNAME ADDRESS CITY STATE
------- -------------------- ==================== --------------- -----
___ U 07160 Reely Great Videos 590 Frontage Rd Boston MA
Cmd F == Table: FOPDEMO.ORDERS(T2) ========================== 1 OF 5 === MORE>>
ORDER_ID CUST_ID ORDER_DATE ORDER_TIME FREIGHT_CHARGES ORDER_SALESMAN
-------- ------- ---------- ---------- --------------- --------------
*** *********************************** TOP ***********************************
___ 1522 07160 04/12/1999 09.27.51 12.00 RP0013
___ 1491 07160 03/29/1999 16.24.41 9.25 RP0013
___ 1305 07160 03/15/1999 10.23.38 12.95 RP0013
___ E 1305 07160 03/15/1999 10.23.38 12.95 RP0013
___ I 1603 07160 07/10/1999 11.04.30 8.75 RP0013
*** ********************************* BOTTOM **********************************
The entire row is duplicated, including the data in the primary key column of that row. In this example, the ORDER_ID column is the primary key. Since this data is defined as unique, an error results when the row is repeated. To correct the error, overtype the data in the primary key column with a unique value.
Alternatively, remove the row in error by using the Access Undo Facility.
The Undo Facility includes the primary command, UNDO ERRORS, to remove all changes that caused an error and the line command, UE, to remove changes that caused an error in a specific row.
Type the UE line command in Cmd for the line in error to remove the repeated row. (For more information about undoing changes, refer to Interacting with the Database.)
An error condition can also occur if any of the inserted or edited data does not conform to the table constraints. These errors are handled like any other error. You can overtype or Undo the changes.
To avoid table constraint errors, you can use the LIST CONSTRAINTS command to display the table constraints for any displayed table while editing.
For example, assume constraints have been defined for the ORDERS table. To indicate a request for the ORDERS table, you can position the cursor on that table or supply the name with the command, as in:
LIST CONSTRAINTS ORDERS
If there is only one constraint, the text is displayed. If there are multiple constraints, a selection list is displayed. In this example, two constraints are defined. The following list is displayed:
Figure: Selection List of Table Constraints
-------------------------------- Optim: Edit ----------------------------------
COMMAND ===> SCROLL ===> PAGE
Cmd F == Table: FOPDEMO.CUSTOMERS(T1) ===================== 10 OF 20 === MORE>>
CUST_ID CUSTNAME ADDRESS CITY STATE
------- -------------------- ==================== --------------- -----
___ U 07160 Reely Great Videos 590 Frontage Rd Boston MA
Cmd F == Table: FOPDEMO.ORDERS(T2) ========================== 1 OF 5 === MORE>>
ORDER_ID CUST_ID ORDER_DATE ORDER_TIME FREIGHT_CHARGES ORDER_SALESMAN
-------- ------- ---------- ---------- --------------- --------------
*** **************** +------ Select Constraint for Table ------+ **************
___ 1522 0716 | Cmd ConstraintName 1 OF 2 | RP0013
___ 1491 0716 | --- --------------------------- | RP0013
___ 1305 0716 | ************* TOP ************* | RP0013
___ I 1603 0716 | ___ ORDER_ID_CON | RP0013
*** **************** | ___ FREIGHT_CHARGES_CON | **************
| ************ BOTTOM ************ |
+-----------------------------------------+
You can display the text associated with any constraint by typing an S in Cmd for that constraint, as in the following example in which the user selected the ORDER_ID constraint. Notice that the table constraint states that the ORDER_ID value must be numeric within a specific range.
Figure: Displayed Table Constraint Text
-------------------------------- Optim: Edit ----------------------------------
COMMAND ===> SCROLL ===> PAGE
Cmd F == Table: FOPDEMO.CUSTOMERS(T1) ===================== 10 OF 20 === MORE>>
CUST_ID CUSTNAME ADDRESS CITY STATE
------- -------------------- ==================== --------------- -----
___ U 07160 Reely Great Videos 590 Frontage Rd Boston MA
Cmd F == Table: FOPDEMO.ORDERS(T2) ========================== 1 OF 5 === MORE>>
ORDER_ID CUST_ID ORDER_DATE ORDER_TIME FREIGHT_CHARGES ORDER_SALESMAN
-------- ------- ---------- ---------- --------------- --------------
*** *********************************** TOP ***********************************
+------------------Text for Constraint: ORDER_ID_CON-----------------------+
| |
| ------------------------------------------------------------------------ |
| ********************************** TOP ********************************* |
| ORDER_ID BETWEEN ‘00000' AND ‘9999' |
| ********************************* BOTTOM ******************************* |
+--------------------------------------------------------------------------+
Use END or CANCEL to return to the selection list. Use END or CANCEL again to return to the edit session.