With DYN_DateCheck As
(Select ‘Select ‘ || ””|| TABLE_NAME ||”” || ‘ As Tbl, ‘ || ””|| COLUMN_NAME||”” || ‘ As Fld, ‘ || ‘Check_Date(‘ || COLUMN_NAME || ‘, :dateformat) As ValidDate ‘ ||
‘From ‘ || TABLE_NAME || ‘_TST ‘ ||
‘Where ‘ || COLUMN_NAME || ‘ IS NOT NULL UNION’
From all_tab_columns
Where NOT OWNER In (‘SYS’, ‘XDB’, ‘GSMADMIN_INTERNAL’ )
And TABLE_NAME In (‘EGL_CLIENTDETAIL’, ‘STG_PLY’, ‘STG_PLR’, ‘STG_IAC’, ‘STG_PPD’)
And DATA_TYPE = ‘DATE’
UNION
Select ‘Select ‘ || ”’XYZ”’ || ‘ As Tbl, ‘ || ”’XYZ”’ || ‘ As Fld, NULL As ValidDate From Dual’ From Dual
Order By 1
)
Select * From (Select * From DYN_DateCheck)
You probably already know this final Select statement won’t actually execute all of the Selects / Unions in DYN_DateCheck – it just provides the dynamic SQL. How can I execute the dynamic Select statements that are in DYN_DateCheck?
I’ve tried Execute Immediate – I don’t really understand that but I don’t how to continue using what is executed. I need to use the results from when this dynamic sql runs.
Mark is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.