UPDATE statement usage
The UPDATE statement is used to modify the data in a table.
Examples of valid IMS Universal JDBC driver UPDATE statements
- Updating one column in a record
- The following statement updates the
root:
UPDATE HOSPITAL SET HOSPNAME = 'MISSION CREEK' WHERE HOSPITAL.HOSPCODE = 'H001007' - Updating multiple columns in a specified record in a hierarchic path
- Foreign keys allow the IMS
Universal JDBC driver to maintain referential
integrity by identifying the exact record (or segment instance) to update. The following statement
updates a WARD record under a specific HOSPITAL. In this example, the WARD table has the foreign key
HOSPITAL_HOSPCODE. The record will be updated if and only if there is a HOSPCODE in the HOSPITAL
table with the value of
'H5140070000H'.
UPDATE WARD SET WARDNAME = 'EMGY', DOCCOUNT = '2', NURCOUNT = '4' WHERE HOSPITAL_HOSPCODE = 'H5140070000H' AND WARDNO = '01'
Examples of invalid IMS Universal JDBC driver UPDATE statements
- Updating a foreign key field
- Making an UPDATE on a foreign key field is invalid for the IMS
Universal JDBC driver. For example, the following
UPDATE query will
fail:
UPDATE WARD SET WARDNAME = 'EMGY', HOSPITAL_HOSPCODE = 'H5140070000H' WHERE WARDNO = '01'