Using column value as table name to delete records
I am using Oracle 8i.
I need to write an Oracle SQL Script to delete records from the selected tables (i.e. EMPLOYEE and ACCOUNT tables, where the TABLE_TYPE column value of MAP_TABLE table is equal to 'A'). But the table names are stored in TABLE_NAME column of MAP_TABLE.
Question 1: How to write the delete statement script for EMPLOYEE and ACCOUNT tables by using the TABLE_NAME column values that retrieved from MAP_TABLE.
Question 2: How to use the TABLE_NAME column values to select a particular field in script, eg. EMP_NAME field of EMPLOYEE table.
TABLE_NUMBER, TABLE_NAME, TABLE_TYPE
1, EMPLOYEE, A
2, ACCOUNT, A
3, STOCK, B
4, RAW, C
100, James Mil
200, Tom Cris
Need advice from expert here. Thanks in advance.
Last edited by mydbuser; 12-09-2003 at 10:42 PM.
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"
yes. got it using dynamic sql.
But, how can I use the dynamic SQL statement to display the multiple records to an output file before the deletion? Mind to share with me the sql. Many Thanks.
Click Here to Expand Forum to Full Width