Support for variable-length database segments with the IMS Universal drivers
The IMS Universal database resource adapter and the IMS Universal JDBC driver manage variable-length segments on behalf of client application programs by default. Application programs that use the IMS Universal DL/I driver must manage the LL field data for variable-length segments.
Using the LL field with the IMS Universal database resource adapter or IMS Universal JDBC driver
By default, the LL field for a variable length segment is returned as a visible column for SQL
queries, and the IMS Universal database resource adapter or IMS Universal JDBC driver manages the LL field on behalf of your
application program. If you use this option, you can make LL field data inaccessible to any query
type (including SELECT *
) by setting the connection property to
false.
Alternatively, you can use your application program to set and control the LL field. To do so, set the llField property to true through the standard properties list of either of the following interfaces:
java.sql.DriverManager.getConnection(String url, Properties properties)
com.ibm.ims.jdbc.IMSDataSource.setProperties(Properties properties)
When the llField=true property is set, the LL field is exposed as a normal column in the standard SQL result set for all operations. You can read, insert, or update the LL field data directly. Deleting the LL field data also deletes the rest of the associated database record. To set a field to the null state, set the length of the segment (the value of the LL field column) to be smaller than the offset of the field within the segment.
The LL field is 2 bytes long and must be handled as BINARY, SHORT, or USHORT data.
You can also use the java.sql.ResultSet.wasNull method to determine whether a nullable field exists in an instance of a variable-length segment without examining the LL data.
Checking for null field instances with the IMS Universal DL/I driver
Applications that use the IMS Universal DL/I driver always receive the LL field data for a variable-length segment. You can determine if a field is null in a segment instance in one of two ways: either compare the LL field data to the offset of the field, or use the com.ibm.ims.dli.Path.wasNull() method.
The com.ibm.ims.dli.Path.wasNull() method returns a boolean value for the null state of the last field that was read. The returned value is true if the field is null. You must attempt to read a field before calling the wasNull() method to determine whether the field is null.