Defining complex horizontal filters

Some situations in database and user management call for the definition of a complex SQL WHERE clause in Subset of rows for individual users field in order to limit the rows that a group or a user can see. When defining the filter, you might refer to a table in the mirror database, use parameters for the group or the user, or use a combination of these methods. For the basic steps in creating a simple horizontal filter, see Filtering data at the subscription level.

DB2 Everyplace Sync Server provides a subset of the standard SQL WHERE implementation to use with the filter. For the syntax of the subset, see Syntax for filters.

The following example demonstrates how you may refer to other tables in the mirror database and use a parameter for horizontal filtering.

Suppose you manage two tables named Ziptab and Business, both of which are in the mirror database. Ziptab contains ZIP codes for certain cities (see Tabulka 208), while Business keeps track of some companies and their ZIP codes (see Tabulka 209). You want users in San Jose, California to view only the businesses in their city. You have created a group and assigned these users to the group.


Tabulka 208. Ziptab table

City Zipcode
San Jose 95141
San Jose 95123
Los Angeles 93002

Tabulka 209. Business table

Business Zip
IBM 95141
My Company 95123
Your Company 93002
Another Company 94888

You would type the following clause in the Subset of rows for individual users field of the Rows page:

(Zip) IN (SELECT Zipcode FROM Ziptab WHERE City = ':fcity')
:fcity is a parameter for the City column value, which you set to San Jose for the group.

Then complete and close the Create Subscriptions notebook. As a result, after synchronization, the users will only see the following rows in Business table on their devices:

Tabulka 210. Rows that the users will see on their devices

Business Zip
IBM 95141
My Company 95123

Související úlohy

Související odkazy