Using the removeInvalidCaseFields property

Use the optional removeInvalidCaseFields connection property to return only columns and fields in a valid map case.

In IMS, you can use DFSMAP and DFSCASE mapping definitions to create multiple field layouts for a segment. Each layout (or “map case”) has a unique ID, and only one layout can be valid at a time. Layouts are controlled by a defined control field, and a layout is valid when its ID matches the control field value.

If you use a SQL SELECT * statement and a WHERE clause with the IMS Universal JDBC driver to retrieve map case fields from a segment, the returned results include all fields by default, including NULL values. You can simplify your results by using the removeInvalidCaseFields property to remove case fields from the result set that do not satisfy the DEPENDINGON field condition in the WHERE clause.

This property only supports use of the equal sign (=) operator in the WHERE clause. If other operators are used, no case fields are removed from the returned result set.

Examples of supported cases are as follows:

  • SELECT * FROM SEGMENT WHERE CONTROLFIELD = ‘VALUE’
  • SELECT * FROM SEGMENT WHERE CONTROLFIELD = ‘VALUE1’ OR CONTROLFIELD = ‘VALUE2’
  • SELECT * FROM SEGMENT WHERE CONTROLFIELD1 = ‘V1’ AND CONTROLFIELD2 = ‘V2’

You must enable the removeInvalidCaseFields property before you can use it.

Enable the removeInvalidCaseFields property

The following code examples show four ways to enable the removeInvalidCaseFields property.

You can enable the removeInvalidCaseFields property in server.xml for use with the IMS Universal Driver:

<connectionFactory jndiName="HOSP_JDBC_T4_EXPANDED">
<properties.imsudbJLocal databaseName="BMP255" datastoreName="IMS1" datastoreServer="localhost" driverType="4" password="myPassword" portNumber="{DRDA_PORT}" user="myUserID" removeInvalidCaseFields="true"/>
</connectionFactory>

You can enable the removeInvalidCaseFields in an IMSManagedConnectionFactory object:

IMSManagedConnectionFactory imsManagedConnectionFactory = new IMSManagedConnectionFactory();
imsManagedConnectionFactory.setremoveInvalidCaseFields(true);

You can use the Driver Manager to enable the removeInvalidCaseFields property via a JDBC URL:

String url=""jdbc:ims://tst.svl.ibm.com:8888/class://"
   + "BMP2.BMP2DatabaseView:datastoreName=IMS1;"
   + "loginTimeout=10;sslConnection=true;user=myUserID;password=myPassword;removeInvalidCaseFields=true;";
Connection conn = DriverManager.getConnection(url);

or

Connection conn = null;

// Create Properties object
Properties props = new Properties();  

// Enable removeInvalidCaseFields
props.put("removeInvalidCaseFields", "true");

// Create connection
conn = DriverManager.getConnection
("jdbc:ims://tst.svl.ibm.com:8888/class://BMP2.BMP2DatabaseView", props);

You can enable the removeInvalidCaseFields property on an IMSDataSource object:

IMSDataSource

IMSDataSource ds = new IMSDataSource();
Properties props = new Properties();
props.setProperty("removeInvalidCaseFields", "true");
props.setProperty("llField", "false");
ds.setProperties(props);

Or

IMSDataSource ds = new IMSDataSource();
ds.setremoveInvalidCaseFields(true);