DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Using column value as table name to delete records

  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Unhappy Using column value as table name to delete records

    Hi,

    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


    EMP_NO, EMP_NAME
    100, James Mil
    200, Tom Cris
    300, Mark
    400, Jessica


    ACC_NO, ACC_CODE
    01, ACDS
    02, SDV
    03, SDV
    04, RFS

    Need advice from expert here. Thanks in advance.

    Chrlyn.
    Last edited by mydbuser; 12-09-2003 at 11:42 PM.

  2. #2
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    Dynamic SQL.
    funky...

    "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"

  3. #3
    Join Date
    Dec 2003
    Posts
    3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width