how can I search for a matching string in all columns of a table and its child tables which has foriegn key relationship and return the result.
Please someone, give me the oracle query for this.
Regards
how can I search for a matching string in all columns of a table and its child tables which has foriegn key relationship and return the result.
Please someone, give me the oracle query for this.
Regards
try this:
SELECT 'select * from ' || table_name || ' where ' || clause
FROM (SELECT DISTINCT REPLACE(stragg(column_name)
over(PARTITION BY table_name ORDER BY table_name), ',',
' = ''__your_string__'' OR ') || ' = __your_string__' clause,
table_name
FROM user_tab_columns
WHERE table_name IN
(SELECT table_name
FROM all_constraints
WHERE constraint_type = 'R'
AND r_constraint_name IN (SELECT constraint_name
FROM all_constraints
WHERE constraint_type IN ('P', 'U')
AND table_name = '__yout_table__')));
Additionally you have to wrap it in a PLSQL or to loop in someway to execute each row of the record set.