DEV Community

Judy
Judy

Posted on

Determine whether to filter again based on the situation in the filtered result set #92

A table in the DB2 database is as follows:

Image description
Now we need to preliminarily filter out records with IDs equal to the specified parameters, and further process them based on whether the ABBREV field in the result set contains "A". If it contains "A", we will further filter out records that only contain "A" and return them; When 'A' is not included, return the preliminary filtering result directly.

For example, when the parameter is equal to 1, it should return:

Image description

When the parameter is equal to 2, return:

Image description

When the parameter is equal to 3, return:

Image description

SPL code:

Image description

A1: Use JDBC to query the database and preliminarily filter out records with IDs equal to the specified parameter.

A2: Further filter records with ABBREV equal to "A". If the result is an empty set, return A1; If the result is not an empty set, return the result of further filtering.

Open source SPL source address

Free Download

Top comments (0)