0

以下の方法でデータを取得する必要があります

     Compare_Result          Association_Type_name     Association_Role 

Type in Dev,but not Prod      ProcessingSite           Null
Role in Dev,but not Prod      ProcessingSite           MoodedActivity
Role in Dev,but not Prod      Specimen                 ProductRelationship

要件:開発と本番を比較する必要があります。association_type または association_role が本番環境に存在しない場合、「型オブジェクトは開発で見つかりましたが、本番環境では見つかりませんでした」のようなメッセージを返す必要があります。

誰でも私にアイデアを教えてください。

サンプルデータ

 create table nodes
 (
 node_id number(5),
 parent_node_id number(5),
 object_id number(5)
 );

 begin
 insert into nodes values(4001,7001,2001);
 insert into nodes values(4002,4001,2005);
 insert into nodes values(4003,4002,2002);
 insert into nodes values(4004,4003,2004);
 insert into nodes values(4005,4004,2003);
 insert into nodes values(4006,4004,2006);
 insert into nodes values(4007,4004,2007);
 insert into nodes values(4008,4003,2008);
 insert into nodes values(4009,4008,2011);
 insert into nodes values(4010,4008,2013);
 insert into nodes values(4011,4008,2014);
 insert into nodes values(4012,4003,2009);
 insert into nodes values(4013,4012,2015);
 insert into nodes values(4014,4012,2017);
 insert into nodes values(4015,4001,2020);
 insert into nodes values(4016,4015,2012);
 insert into nodes values(4017,4016,2016);
 insert into nodes values(4018,4017,2024);
 insert into nodes values(4019,4017,2023);
 insert into nodes values(4020,4016,2029);
 insert into nodes values(4021,4020,2022);
 insert into nodes values(4022,4020,2021);
 insert into nodes values(4023,4020,2019);
 insert into nodes values(4024,4016,2010);
 insert into nodes values(4025,4024,2018);
 end;
 /

 create table objects
 (
 object_id number(5),
 object_type_id number(5),
 name varchar2(40)
 );

 begin
 insert into objects values ( 2001,5001,'iad_Dictionary_area');
 insert into objects values ( 2002,5003,'iad_Association_Dictionary');
 insert into objects values ( 2003,5005,'TreatingSite');
 insert into objects values ( 2004,5004,'ProcessingSite');
 insert into objects values ( 2005,5002,'Development');
 insert into objects values ( 2006,5005,'MoodedActivity');
 insert into objects values ( 2007,5005,'MaterialName');
 insert into objects values ( 2008,5004,'PerformedClass');
 insert into objects values ( 2009,5004,'Specimen');
 insert into objects values ( 2010,5004,'Specimen');
 insert into objects values ( 2011,5005,'RegulatoryAssessment');
 insert into objects values ( 2012,5003,'iad_Association_Dictionary');
 insert into objects values ( 2013,5005,'Submission');
 insert into objects values ( 2014,5005,'Mooded');
 insert into objects values ( 2015,5005,'class13th');
 insert into objects values ( 2016,5004,'ProcessingSite');
 insert into objects values ( 2017,5005,'ProductRelationship');
 insert into objects values ( 2018,5005,'class13th');
 insert into objects values ( 2019,5005,'Distributor');
 insert into objects values ( 2020,5006,'Production');
 insert into objects values ( 2021,5005,'Assessor');
 insert into objects values ( 2022,5005,'StudyInvestigator');
 insert into objects values ( 2023,5005,'MaterialName');
 insert into objects values ( 2024,5005,'TreatingSite');
 insert into objects values ( 2029,5004,'BiologicEntityGroup');
 end;
 /

 create table object_types
 (
 object_type_id number(5),
 name varchar2(35)
 );

 begin
 insert into object_types values (5001,'Dictionary_area');
 insert into object_types values (5002,'Development');
 insert into object_types values (5003,'Association_Dictionary');
 insert into object_types values (5004,'Association_Type');
 insert into object_types values (5005,'Association_Role');
 insert into object_types values (5006,'Production');
 end;
 /

私は以下の構造を持っていると仮定しましょう

  Dictionary_area
      development
          Association_Dictionary 
                ProcessingSite(type1) 
                    TreatingSite(role1)
                    MoodedActivity(role2)
                    MaterialName(role3)


                PerformedClass(type2)
                    RegulatoryAssessment(role1)
                    Submission(role2)
                    Mooded(role3)

                Specimen(type3)
                    class13th(role1)
                    ProductRelationship(role2)      

       production
          Association_Dictionary
                ProcessingSite(type1)
                    TreatingSite(role1)
                    MaterialName(role2)

                BiologicEntityGroup(type2)
                    StudyInvestigator(role1)
                    Assessor(role2)
                    Distributor(role3) 

                Specimen (type3)      
                    class13th(role1)

ProcessingSite は association_type であり、3 つの association_roles を持っています。プロダクションで同じ Association_type を確認できますが、MoodedActivity(association_role) は利用できません。この場合、「タイプ オブジェクトは開発で見つかりましたが、本番では見つかりませんでした」を返す必要があります。

テーブル情報

ノード: このテーブルには、ノードと親ノードの情報が含まれます。たとえば、開発オブジェクトに 100 のようなノードがあり、その親ノードが 99 の場合。

オブジェクト: オブジェクト情報。

object_types: object_type 情報。たとえば、ProcessingSite object_type は「Association_Type」です。

私は以下の方法で試しました

 WITH childs AS
 (SELECT n.object_id, n.node_id, n.parent_node_id, ot.NAME, "path",
         rootnode
    FROM (SELECT     object_id, node_id, parent_node_id,
                     SYS_CONNECT_BY_PATH (object_id, '/') "path",
                     CONNECT_BY_ROOT (object_id) rootnode
                FROM nodes

          START WITH object_id = 2001
          CONNECT BY PRIOR node_id = parent_node_id) n
         JOIN
         objects o ON n.object_id = o.object_id
         JOIN object_types ot ON o.object_type_id = ot.object_type_id
         ),
 devobj AS
 (SELECT n.object_id, n.NAME
    FROM (SELECT *
            FROM childs) n
   WHERE n.NAME = 'Development'),
 prodobj AS
 (SELECT n.object_id, n.NAME
    FROM (SELECT *
            FROM childs) n
   WHERE n.NAME = 'Production'),
 dev_associ_type_obj AS
 (SELECT *
    FROM (SELECT     object_id, NAME
                FROM (SELECT *
                        FROM childs)
          START WITH object_id = (SELECT object_id
                                    FROM devobj)
          CONNECT BY PRIOR node_id = parent_node_id) t
   WHERE t.NAME = 'Association_Type'),
 dev_associ_roles_obj AS
 (SELECT     object_id, NAME, CONNECT_BY_ROOT (object_id) rootnode
        FROM (SELECT *
                FROM childs)
  START WITH object_id IN (SELECT object_id
                             FROM dev_associ_type_obj)
  CONNECT BY PRIOR node_id = parent_node_id),
 prod_associ_type_obj AS
 (SELECT *
    FROM (SELECT     object_id, NAME
                FROM (SELECT *
                        FROM childs)
          START WITH object_id = (SELECT object_id
                                    FROM devobj)
          CONNECT BY PRIOR node_id = parent_node_id) t
   WHERE t.NAME = 'Association_Type'),
 prod_associ_roles_obj AS
 (SELECT     object_id, NAME, CONNECT_BY_ROOT (object_id) rootnode
        FROM (SELECT *
                FROM childs)
  START WITH object_id IN (SELECT object_id
                             FROM prod_associ_type_obj)
  CONNECT BY PRIOR node_id = parent_node_id)
  SELECT *
  FROM prod_associ_roles_obj
  MINUS
  SELECT *
  FROM dev_associ_roles_obj
4

0 に答える 0