Filter Unparsable Queries
| This feature is available only in Enterprise Edition. |
In some cases, the server may not be able to parse highly complex SQL queries, or those that contain custom database syntax. If a query is unparsable, the server cannot automatically identify the columns being returned by the query, and therefore cannot automatically apply the VPM security model.
To enable VPM filtering for an unparsable query, you must embed special tags into the query’s SQL string. These tags supply information to the server about hidden columns and filtering conditions. The special tags are listed below.
To specify the security for a particular returned query column, you need to associate the given query column with one of the hidden columns in the vpm.columns list. To do this, wrap the query column inside a pair of /*<idx>*/ tags, and set idx to the index of the listed column from which the query column should inherit security. If the VPM defines filtering conditions for any one of the tables in the vpm.tables list, those conditions will be applied within the ‘/*<where>*/’ tags.
Consider the following SQL query:
select SA.CUSTOMERS.COMPANY_NAME,SA.ORDER_DETAILS.QUANTITY+10, SA.ORDERS.DISCOUNT,SA.PRODUCTS.PRODUCT_NAME,SA.PRODUCTS.PRICE,SA.PRODUCTS.DESCRIPTION
from SA.CUSTOMERS, SA.ORDER_DETAILS, SA.ORDERS, SA.PRODUCTS
where SA.ORDER_DETAILS.PRODUCT_ID = SA.PRODUCTS.PRODUCT_ID
and SA.ORDERS.ORDER_ID = SA.ORDER_DETAILS.ORDER_ID
and SA.ORDERS.CUSTOMER_ID = SA.CUSTOMERS.CUSTOMER_ID
Assume that this query is unparsable (for whatever reason), and that you want to apply security to the CUSTOMERS.COMPANY_NAME and ORDER_DETAILS.QUANTITY+10 columns returned by the query, and that you also want to apply a VPM filter to the where clause.
To configure the above security settings, follow these steps:
-
In the Hidden Columns tab, add the
SA.CUSTOMERS.COMPANY_NAMEandSA.ORDER_DETAILS.QUANTITYcolumns to the ‘Hidden Columns’ list. (See Create a Hidden Column.) -
Specify the desired VPM filtering conditions in the Conditions tab. (See Create a Condition.)
-
Open the query for editing in a Data Worksheet. (See Query Data.) Click the SQL String tab to edit the query SQL as follows.
-
Place the
/*<where>*/tags around thewhereclause of the query:/*<where>*/SA.ORDER_DETAILS.PRODUCT_ID = SA.PRODUCTS.PRODUCT_ID and SA.ORDERS.ORDER_ID = SA.ORDER_DETAILS.ORDER_ID and SA.ORDERS.CUSTOMER_ID = SA.CUSTOMERS.CUSTOMER_ID/*</where>*/Line breaks are used above only for clarity. Do not use line breaks between two special tags in your query. -
Add the following tags at the beginning of the query:
--vpm.tables:SA.CUSTOMERS,SA.ORDER_DETAILS,SA.PRODUCTS --vpm.columns:SA.ORDER_DETAILS.QUANTITY,SA.CUSTOMERS.COMPANY_NAMEFiltering conditions defined by the VPM on the specified tables (
vpm.tables) will be applied within the/*<where>*/tags. The specified columns (vpm.columns) will be referenced by the/*<idx>*/tags in the queries, in the next step.The SQL query must remain valid when the material enclosed by tags is removed. Commas should therefore be placed inside the tags. Line breaks may not occur between two special tags. -
Add
/*<idx>*/tags around the query columns that will inherit security:select /*<2>*/SA.CUSTOMERS.COMPANY_NAME,/*</2>*/ /*<1>*/SA.ORDER_DETAILS.QUANTITY+10,/*</1>*/ ...Note that the index
idxrefers to the location of the corresponding hidden column in thevpm.columnslist. Therefore, the tag/*<1>*/refers to the first item in thevpm.columnslist, which isORDER_DETAILS.QUANTITY. This means that the returned columnSA.ORDER_DETAILS.QUANTITY+10inherits security from the hidden columnORDER_DETAILS.QUANTITY.
The complete tagged query is shown below:
--vpm.tables:SA.CUSTOMERS,SA.ORDER_DETAILS,SA.PRODUCTS
--vpm.columns:SA.ORDER_DETAILS.QUANTITY,SA.CUSTOMERS.COMPANY_NAME
select /*<2>*/SA.CUSTOMERS.COMPANY_NAME,/*</2>*/ /*<1>*/SA.ORDER_DETAILS.QUANTITY+10,/*</1>*/ SA.ORDERS.DISCOUNT,SA.PRODUCTS.PRODUCT_NAME,SA.PRODUCTS.PRICE,SA.PRODUCTS.DESCRIPTION
from SA.CUSTOMERS, SA.ORDER_DETAILS, SA.ORDERS, SA.PRODUCTS
where /*<where>*/SA.ORDER_DETAILS.PRODUCT_ID = SA.PRODUCTS.PRODUCT_ID and SA.ORDERS.ORDER_ID = SA.ORDER_DETAILS.ORDER_ID and SA.ORDERS.CUSTOMER_ID = SA.CUSTOMERS.CUSTOMER_ID/*</where>*/