Troubleshooting
Problem
Given a sample query which makes use of table aliases as follows:
SELECT TOP 1 p.col_1, ss.col_2 FROM tab_p p
And the following query rewrite action:
Change 'col_1' to 'LEFT(col_1,4) + '****' AS col_1' (use regex and all rule = false)
An 'Ambiguous Column Name' error is returned when the sample query is run.
Diagnosing The Problem
The SQL statement is expected to be re-written by Guardium as follows :-
SELECT TOP 1 LEFT(p.col_1,4) + '****' AS col_1, ss.col_2 FROM tab_p p
However, Guardium is instead rewriting the query without prefixing the columns names with the alias:-
SELECT TOP 1 LEFT(col_1,4) + '****' AS col_1, ss.col_2 FROM tab_p p
This will result in the error described above as the col_1 field has now become ambiguous, since the rewritten query doesn't include the 'p.' identifier.
Resolving The Problem
This is expected behaviour .
Guardium does not support query rewrite with the use of table aliases, as the alias can refer to anything.
It is impossible to cover all possible scenarios where aliases can be used and provide correct re-written sql.
Guardium does not support query rewrite with the use of table aliases, as the alias can refer to anything.
It is impossible to cover all possible scenarios where aliases can be used and provide correct re-written sql.
A method to work around this is suggested as follows:-
Have the REAL table name before the column name in the replace to string function
e.g.
Have the REAL table name before the column name in the replace to string function
e.g.
Change 'col_1' to 'LEFT(tab_p.col_1,4) + '****' AS col_1' (use regex and all rule = false)
Document Location
Worldwide
[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSMPHH","label":"IBM Security Guardium"},"Component":"","Platform":[{"code":"PF004","label":"Appliance"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB24","label":"Security Software"}}]
Was this topic helpful?
Document Information
Modified date:
02 February 2019
UID
ibm10869036