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

Thread: Referential Integrity

  1. #1
    Join Date
    Jan 2003
    Location
    Melbourne, Australia
    Posts
    8

    Referential Integrity

    I am trying to work out the order in which to delete records from the tables in one of my databases.

    There are multiple foreign keys and no matter how I try, I can't work out what is the order in which to do it.

    Does anyone have a suggestion?

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    create or replace procedure parent_child(tname varchar2,p_chr varchar2 default '*') IS
    l_child varchar2(255):='';
    l_chr varchar2(255):='';
    l_tname varchar2(255):='';
    begin
    if p_chr='*' THEN
    dbms_output.put_line('Parent table : '||tname);

    end if;
    for crec in (select * from all_constraints where table_name=tname
    and constraint_type='P') loop
    l_tname:=tname;

    for crec1 in
    (select * from all_constraints
    where r_constraint_name=crec.constraint_name)
    loop
    parent_child(crec1.table_name,'$');

    l_child:=crec1.owner||'.'||crec1.table_name;

    IF length(l_child)>=1 THEN
    dbms_output.put_line('child table : '||l_child);
    END IF;
    end loop;

    end loop;
    END;

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