composite unique constraint on the values of parent and child?

Is it possible to have a composite unique constraint that contains the values of the child elements? The example below has the "child" elements are offline, but it's preferred, but optional, I know that you can have a unique constraint in the set of tables without using a reference table that contains the constraint and the two columns. How xdb manages this requirement?

permit:
<parent ID="1">
   <child><name>test1</name></child>
   <child><name>test2</name></child>
</parent>
<parent ID="2">
   <child><name>test1</name></child>
   <child><name>test2</name></child>
</parent>
not allowed:
<parent ID="1">
   <child><name>test1</name></child>
   <child><name>test1</name></child>
</parent>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:xdb="http://xmlns.oracle.com/xdb"
           xdb:storeVarrayAsTable="true"
           elementFormDefault="qualified">
    
    <xs:element name="parent" type="Parent_T"
        xdb:columnProps="CONSTRAINT parent_pkey PRIMARY KEY (XMLDATA.ID)"
        xdb:defaultTable="PARENT"/>

    <xs:complexType name="Parent_T" xdb:SQLType="PARENT_T" xdb:maintainDOM="false">
        <xs:sequence>
            <xs:element name="child" type="Child_T" minOccurs="1" maxOccurs="unbounded" xdb:SQLName="CHILD"
                      xdb:SQLInline="false" xdb:defaultTable="CHILD" "/>
        </xs:sequence>
        <xs:attribute name="ID" xdb:SQLName="ID" use="required" />
    </xs:complexType>
    
    <xs:complexType name="Child_T" xdb:SQLType="CHILD_T">
       <xs:sequence>
         <xs:element name="name" type="xs:string" xdb:SQLName="NAME"/>
       </xs:sequence>
     </xs:complexType>     
</xs:schema>
xdb:columnProps = "CONSTRAINT parent_pkey PRIMARY KEY (XMLDATA.ID), * UNIQUE (XMLDATA.» "Child.Name) *" triggers the non-existent attribute


A possible solution would be to copy the value of the primary key parent of the child element, then I could create a composite unique constraint using only the values of the child. However, I have this same requirement elsewhere in my lowest nested schema, and it can become messy / bad design with cascading of all primary keys on the schema. For example, I have a recursive element in which two attributes must be unique only within the parent company:
<parent id="1">
   <child a="1" b="1">
      <child a="1" b="2">
         <child a="1" b="1" /> *not allowed
      </child>
   </child>
   <child a="1" b="2" /> *not allowed
</parent>
Possible solution:
<child a="1" b="2" parent_id="1" />
<xs:complexType name="Child_T>
   <xs:sequence>
      <xs:element name="child" xsd:SQLInline="false" xsd:columnProps="UNIQUE(XMLDATA.a,XMLDATA.b,XMLDATA.parent_id)" minOccurs="0" maxOccurs="unbounded" type="Child_T">
   </xs:sequence>
   </xs:element
</xs:complexType>
Is there a better design?

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi 
PL/SQL Release 10.2.0.4.0 - Production                           
CORE     10.2.0.4.0     Production                                       
TNS for Linux: Version 10.2.0.4.0 - Production                   
NLSRTL Version 10.2.0.4.0 - Production 

You can do something like this:

SQL> DECLARE
  2
  3    xsd_doc xmltype := xmltype('
  4  
  5    
  6      
  7        
  8          
  9        
 10      
 11    
 12    
 13      
 14        
 15          
 16        
 17      
 18    
 19    
 20      
 21        
 22          
 23        
 24        
 25      
 26    
 27    
 28      
 29        
 30          
 31        
 32      
 33    
 34  ');
 35
 36  BEGIN
 37
 38    dbms_xmlschema.registerSchema(
 39      schemaURL => 'test_parent.xsd',
 40      schemaDoc => xsd_doc,
 41      local => true,
 42      genTypes => true,
 43      genbean => false,
 44      genTables => false,
 45      enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE
 46    );
 47
 48  END;
 49  /

PL/SQL procedure successfully completed

SQL> CREATE TABLE my_xml_table OF XMLTYPE
  2  XMLTYPE STORE AS OBJECT RELATIONAL
  3  XMLSCHEMA "test_parent.xsd"
  4  ELEMENT "root"
  5  VARRAY xmldata."parent" STORE AS TABLE my_parent_tab
  6  (
  7    VARRAY "child" STORE AS TABLE my_child_tab
  8  )
  9  ;

Table created

SQL> ALTER TABLE my_parent_tab ADD CONSTRAINT parent_uk UNIQUE (nested_table_id, "ID");

Table altered

SQL> ALTER TABLE my_child_tab ADD CONSTRAINT child_uk UNIQUE (nested_table_id, "name");

Table altered
 

Then:

SQL> insert into my_xml_table values (
  2  xmltype('
  3     test1
  4     test2
  5  
  6  
  7     test1
  8     test2
  9  ')
 10  );
insert into my_xml_table values (
*
ERREUR à la ligne 1 :
ORA-00001: violation de contrainte unique (DEV.PARENT_UK)

SQL> insert into my_xml_table values (
  2  xmltype('
  3     test1
  4     test1
  5  
  6  
  7     test1
  8     test2
  9  ')
 10  );
insert into my_xml_table values (
*
ERREUR à la ligne 1 :
ORA-00001: violation de contrainte unique (DEV.CHILD_UK)

SQL> insert into my_xml_table values (
  2  xmltype('
  3     test1
  4     test2
  5  
  6  
  7     test1
  8     test2
  9  ')
 10  );

1 ligne créée.

http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14259/xdb06stt.htm#sthref987

Tags: Database

Similar Questions

  • Unique constraint on the values in both directions

    I'm looking to create a unique constraint that works in two ways. Say I got a constraint unique in columns 1 and 2. I want it to be impossible for the two lines below the two exist at the same time. Is there a way to do this? I googled around for a while now and I found nothing that works so far.

    Header 1 Header 2
    DogCAT
    CATDog

    Hello

    You can create an index based on a single function:, like this:

    CREATE UNIQUE INDEX table_x_header_1_header_2

    ON table_x (LESS (header_1, header_2)

    More LARGE (header_1, header_2)

    );

    How will you use these values?  You might be better to simply create a regular old unique constraint, but also have a CHECK constraint to ensure that header_1<= header_2. ="" that="" way,="" when="" you="" want="" to="" search="" for="" the="" combination="" ('cat',="" 'dog')="" you="" won't="" have="" to="" search="" for="" ('dog',="" 'cat')="">

  • Look for the logic find the value of m and c of this equation y = mx + c.

    Hello

    I have 4 points for example = 3.38276, 0.375866 xi

    Yi = 3.37749, 0.281924

    using this tip, I want to find the value of m and c.

    You please suggest me some logic to solve this equation using labview programming.

    I tried with one solution, but in this case I do not have the correct answer. Here as an attachment, there is vi help I tried to solve my equation, but in this case the value that never got as a response it is dissatisfied with the equation, means if I replace the value of m and c eqation then it must be L.H.S = R.H.S, but I don't have the right solution.

    You please guide me.

    Thank you very much.

    Why do you think that the results are incorrect? I put your numbers in your code and the result on a XY Chart Wescott, I then bunk which with more than 20 values with a value ranging from 0.6 to 3.2 x and use factors calculated in your code to generate values of Y. The two overlap almost exactly...

    Mike...

    BTW: There is a linear adjustment integrated into LV VI

  • How is a parent and child, rights and roll determind in the script

    How is a parent and child, rights and roll determind in the script as an exe of java or xml. It's first and second user and which assings these rolls? thanx

    Hello

    Thanks for posting your question in the Microsoft Community.

    Sinc you want to determine the parent and the child rights usings script as an exe of java or xml, the question you posted would be best suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums for further assistance:

    MSDN forums

  • Calc help - copy all the accounts from Parent to child

    I was copying some accounts from Parent to child by listing each account using a Sun cross. The child, that I am focusing the attribute is "Open". But now I need to copy all the accounts from parent to child, and there may be hundreds of accounts. Is there a way to move all of them at once rather than list them one at a time?

    DIFFICULTY (& "ScenarioA", "Esityksen", CurrYr, Jan,@RELATIVE("Entity",0) AND @Attribute ("Open"))

    'Sales' = 'Dirty'-> @Parent (@Currmbr ("Entity"));

    "Salary" = "salary"-> @Parent (@Currmbr ("Entity"));

    EndFix

    Of course, exchanging places with your accounts and periods.

    DIFFICULTY (& CurrYr, "ScenarioA", "Esityksen", @RELATIVE("Account",0), @RELATIVE("Entity",0) AND @Attribute ("Open"))

    "Jan" = "Jan"-> @Parent (@Currmbr ("Entity"));

    EndFix

    Sabrina

  • Error: the capacity of the disk virtual parent and the child disk capacity are different (67).

    Hello

    I tried to increase the hard drive of a machine space of 10 GB for a 20 GB virtual linux. I closed down the VM, then ssh was in the ESXi server. From there on, I ran the command:

    vmkfstools x 20 G Apatite.vmdk

    The command was executed successfully. Then, when I turned on the virtual machine I had and still do me:

    Reason: The capacity of the disk virtual parent and the child disk capacity are different.
    Cannot open disk ' / vmfs/volumes/503fd5b8-d1cef086-eb4a-10bf487b38db/Apatite/Apatite-000001.vmdk' or one of the snapshot disks it depends on.

    I tried many things such as the cloning of the Apatite.vmdk of Apatite - repaired.vmdk. That works, however, I get an old version of the virtual machine. I do not receive my changes of Apatite - 000001.vmdk or Apatite-000001 - delta.vmdk.

    I have a very important job on my VM that I am restoring. I should have backed up before doing anything else I've done. Now, it seems that I pay the price.

    Can someone help me get my VM? Is it possible to increase the size of the snapshot (Apatite - 000001.vmdk) or reduce the size of the parent so that they match, and the virtual machine start?

    Help, please.

    Thank you

    Apatite - 000001.vmdk
    # Disk DescriptorFile
    version = 1
    Encoding = 'UTF-8 '.
    CID = 79c3c056
    parentCID = cf2ec09b
    isNativeSnapshot = 'no '.
    createType = "vmfsSparse."
    parentFileNameHint = "Apatite.vmdk"
    # Description of the measure
    RW 41943040 VMFSSPARSE ' Apatite-000001 - delta.vmdk.
    # The database disk
    #DDB
    ddb.longContentID = "11ad79de6b5a5fe9218cfd7179c3c056".
    ddb.toolsVersion = "9216.
    modified entries are marked in red
    After you have made the changes - do NOT start the virtual machine
    Instead, remove from inventory and run
    vmkfstools 'Apatite - 000001.vmdk'-i 'consolidated.vmdk' d slim
    When did edit the vmx file and replace
    scsi0:0. FileName = 'Apatite - 000001.vmdk ".
    with
    scsi0:0. FileName = "consolidated.vmdk".
    now, you can save the VM again.
  • Simply select the values between min and max of a value accumulated during the day

    Hello Forum,

    a value is accumulated more a day and over a period of time. The next day, the value is reset and starts to build up again:
    with sampledata as (select to_date('09.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 23 val from dual union all
                       select to_date('09.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 29 val from dual union all
                       select to_date('09.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 30 val from dual union all
                       select to_date('09.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 45 val from dual union all
                       select to_date('09.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 60 val from dual union all
                       select to_date('09.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 75 val from dual union all
                       select to_date('09.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 95 val from dual union all
                       select to_date('09.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('09.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 17:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('09.09.2012 23:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 00:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 01:03:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 02:54:11', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 03:04:08', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 04:04:19', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 05:04:20', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 06:12:02', 'dd.mm.yyyy hh24:mi:ss') ts, 14 val from dual union all
                       select to_date('10.09.2012 07:12:03', 'dd.mm.yyyy hh24:mi:ss') ts, 34 val from dual union all
                       select to_date('10.09.2012 08:12:04', 'dd.mm.yyyy hh24:mi:ss') ts, 58 val from dual union all
                       select to_date('10.09.2012 09:12:11', 'dd.mm.yyyy hh24:mi:ss') ts, 70 val from dual union all
                       select to_date('10.09.2012 10:12:12', 'dd.mm.yyyy hh24:mi:ss') ts, 120 val from dual union all
                       select to_date('10.09.2012 11:12:13', 'dd.mm.yyyy hh24:mi:ss') ts, 142 val from dual union all
                       select to_date('10.09.2012 12:21:24', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 13:21:26', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 14:21:27', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 15:21:30', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 16:21:32', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual union all
                       select to_date('10.09.2012 21:21:33', 'dd.mm.yyyy hh24:mi:ss') ts, 153 val from dual)
    select   ts, val
    from     sampledata
    order by ts asc;
    How should I change the select statement to ignore all data sets before the first minimum and duplicates after the maximum of a day to get such a result:
    TS     VAL
    09.09.12 06:12     23
    09.09.12 07:12     29
    09.09.12 08:12     30
    09.09.12 09:12     45
    09.09.12 10:12     60
    09.09.12 11:12     75
    09.09.12 12:21     95
    09.09.12 13:21     120
    09.09.12 14:21     142
    10.09.12 06:12     14
    10.09.12 07:12     34
    10.09.12 08:12     58
    10.09.12 09:12     70
    10.09.12 10:12     120
    10.09.12 11:12     142
    10.09.12 12:21     153
    Thank you

    Hello

    msinn wrote:
    Hello Forum,

    a value is accumulated more a day and over a period of time. The next day, the value is reset and starts to build up again:

    Thanks for posting the sample data and results. Be sure to explain how you get these results from these data. For example "for each day, I just want to show the lines after the daily low was reached. For example, on September 9, the lowest val was 23, which occurred at 6:12, so I don't want to show all lines earier to 06:12 September 9. In addition, when a val is the same as or more than the previous same day val (in order by ts), then I don't want to display the line later. For example, on 9 September, there are several consecutive lines, starting at 14:21 which all have the same val, 142. I want to only display the ealiest of this group, the line of 14:21. »

    Here's a way to do it, using analytical functions:

    WITH   got_analytics     AS
    (
         SELECT  ts, val
         ,     MIN  (val) OVER ( PARTITION BY  TRUNC (ts)
                                  ORDER BY       ts  DESC
                        )      AS min_val_after
         ,     CASE
                  WHEN  val = MIN (val) OVER (PARTITION BY  TRUNC (ts))
                  THEN  -1    -- Impossibly low val.  See note below
                  ELSE  LAG  (val) OVER ( PARTITION BY  TRUNC (ts)
                                              ORDER BY         ts
                               )
              END      AS prev_val
         FROM    sampledata
    )
    SELECT       ts
    ,       val
    FROM       got_analytics
    WHERE       val     <= min_val_after
    AND       val     >  prev_val
    ORDER BY  ts
    ;
    

    This requires that val > = 0. If you don't know a lower bound for val, and then the same basic approach still works, but it's a bit messier.

  • Definition of the values of height and width of a clip with XML file!

    How can I specify values of height and width of a clip using the external XML file? The user needs change the values of a specific clip [rectangular] using the xml file.

    How can I do?

    Thank you.

    You have difficulties with what part of the assistance from an xml file to store and retrieve data?  Do you know how to write the values of height and width, in the form of data in an xml file?  It could be something as simple as the following...

    200

    200

  • Parsing sql - cursor parent and child

    Hi all

    What is the parent and child when parsing sql cursor?

    Thank you

    John

    Well, as Anand mentioned you could yourself. Here's a demo of the workaround based. Based on the change of environment, the sliders would be created and will not be shared that I made using the change of parameter of optimizer_mode. This is done in 11201 with the setting optimizer_features_enable on 10201.

    SQL> drop table t purge;
    
    Table dropped.
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> alter system flush shared_pool;
    
    System altered.
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    no rows selected
    
    SQL> save a
    Created file a.sql
    SQL> select * from t;
    select * from t
                  *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    SQL> create table t(a char);
    
    Table created.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    select * from T
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    VERSION_COUNT EXECUTIONS
    ------------- ----------
    select * from t
                1          1
    
    select * from T
                1          1
    
    SQL> column sql_text format a40
    SQL> /
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from T                                      1          1
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    ----------------------------------------
    select * from t
    select * from T
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from T                                      1          2
    
    SQL> alter session set optimizer_mode=first_rows;
    
    Session altered.
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from test_sharing where id=:a               1          3
    select * from test_sharing where id=1                1          0
    select * from test_sharing where id=99               1          0
    select * from T                                      2          3
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    
    6 rows selected.
    
    SQL> alter session set optimizer_mode=first_rows_1;
    
    Session altered.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    
    6 rows selected.
    
    SQL> alter session set sql_trace=true;
    
    Session altered.
    
    SQL> alter session set optimizer_mode=first_rows_1;
    
    Session altered.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      2          3
    select * from test_sharing where id=:a               1          3
    select * from test_sharing where id=1                1          0
    select * from test_sharing where id=99               1          0
    select * from T                                      3          5
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from t                                     1 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    select * from T                                     2 FIRST_ROWS      1601196873
    
    8 rows selected.
    
    SQL> select sql_id,sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'selec
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS
         1601196873
    
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS
         1601196873
    
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS
         3492249339
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS
         3492249339
    
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS
         2354865636
    
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS
         1601196873
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS
         1601196873
    
    8 rows selected.
    
    SQL> set pagesize 9999
    SQL> /
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS
         1601196873
    
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS
         1601196873
    
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS
         3492249339
    
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS
         3492249339
    
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS
         2354865636
    
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS
         1601196873
    
    8 rows selected.
    
    SQL> set linesize 200
    SQL> /
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ------------- ---------------------------------------- ------------ ---------- ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS      1601196873
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS      1601196873
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS        1601196873
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS      1601196873
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS      1601196873
    
    8 rows selected.
    
    SQL> select child_number, child_address, stats_row_mismatch, optimizer_mode_mismatch
      2  from v$sql_shared_cursor where sql_id='ahgbnyrbh7bp1';
    
    CHILD_NUMBER CHILD_AD S O
    ------------ -------- - -
               0 1A610050 N N
               1 1F148DA4 N Y
               2 1A630C90 Y N
    
    SQL>
    

    You can see an inconsistency in the optimizer_mode resulting in another creation of child cursor. You can try to use the parameter cursor_sharing similar value and bind variables that would also cause child several sliders to create. For the view V$ sql_shared_cursor, check the docs.

    HTH
    Aman...

    PS: Please don't bump up to the thread. This is not support so people are not forced to update immediately. All are volunteers so assume that they would update the thread as and when they have / get time to do.

  • Cursors for parent and child, bind variable and library cache

    I was going through the documentation to understand the difference between the parent and the child cursors. Surprisingly, there's not too much help for this. I was able to collect the following information about this

    For each statement SQL cache library contains a cursor "parent" for the text of the SQL statement. The parent cursor is composed of a "handle" that can be searched by the hash value via the library cache hash table and an «object' which contains pointers to each of its «child» cursors Each cursor of the child is also composed of a handle and an object. The child object is composed of two segments numbered from 0 to 6. Lot 0 contains all the credentials for a particular version of the SQL statement and lot 6 contains the execution plan. This distinction between parent and child cursors is maintained even when there is only one version of each SQL statement.

    Lets say that 2 LMD were fired with the same set of variables bind (names of variables were same but differed from the value.) The only difference between the 2 LMD was the value of the variable binding) and under the same conditions of load.

    These DML 2 would be a sliders 2 children of one parent only cursors.

    Please tell me detailed documentation on the subject, so my question is too elementary

    Kind regards
    Vishal

    I'm not sure how useful jumping in stuff like bunch 0 and 6 bunch is in terms of understanding what is a parent and what is a child cursor.
    This quote seems to come from Steve Adams - http://www.ixora.com.au/q+a/0104/19005414.htm
    It's a good idea to cite your references.

    I'll give it a go.

    A cursor is a lot of information stored in memory on a SQL statement.

    The basic information for a parent cursor is the text of the SQL statement - exact matches of the statement can only share the parent cursor.

    The cursor of the child is really on the implementation plan specific for a statement and the different settings and parameters that caused this plan to be generated.

    There are a whole bunch of reasons why the executions of the same SQL statement may or may not reuse the existing child cursors.

    In your example 2 statements that differ by the variable binding are likely to lead to different children, although there are factors that can lead to lie different values, do not share the same children among whom for example, the length of the dregs, Adaptive setting cursor_sharing = similar and histograms, or new features like cursor sharing (on subsequent runs of renowned sql running suboptimal initially).

    It might be useful to see V$ SQL_SHARED_CURSOR. This shows the disparities that cause children to not be shared. There are more than 60 columns in this view which gives an indication of the number of factors that can influence.
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17110/dynviews_3059.htm#REFRN30254

    You might want to look here the criteria for sharing SQL:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e16638/memory.htm#i40017

    Away from the main documentation, perhaps some of the writings of the optimizer Development Group could help?
    http://blogs.Oracle.com/mt/mt-search.cgi?blog_id=3361&tag=cursor%20sharing&limit=20

    Christian Antognini described this area very well in the "Oracle Performance Troubleshooting Guide".

    Published by: Dom Brooks on February 24, 2011 16:45

  • Unique constraint in the form of master detail error

    Hi all

    I need help, the following requirement.

    I have a master detail form developed on master-child table. the tables have the composite key.

    Old masters has a composite key on columns (A, B)

    Children table has a composite key on columns (A, B, C)

    Child block look something like below

    C       A          B

    10 AAA 1000

    20 1300 BBB

    30 CCC 1400

    40 DDD 1200

    Increments of column C with 10 for each record, and if a new record is insert in intermediaries the records it is incremented to 5.

    My requirement is when an end user attempts to insert record between 20 and 30 or 30 and 40 and clicks on save, the value of the C column must regenerate as shown below

    C       A          B

    10 AAA 1000

    20 1300 BBB

    XXX 30 900

    40 CCC 1400

    50 DDD 1200

    Button Save I wrote the following code

    Declare
      ln_Count NUMBER :=0;
      ln_c number :=0
      cursor c1 is
      select c
      from child
      where a=:child.a
      and b=:child.b
    Begin
      Go_Block('Child');
      First_Record;
      LOOP
      ln_Count:= ln_Count+10;
      :child.C := ln_Count;
      EXIT When :System.Last_Record = 'TRUE';
      Next_Record;
      END LOOP;
    
    
      For c_cur in c1 Loop
      update child
      set c:=ln_c+10
      where a=:child.a
      and b=:child.b 
      and c=c_cur.c
      end loop;
      Forms_DDL('commit');
         
         commit_prc('Commit');  -- We have our own program unit to call commit_form
    
    END;
    

    I tried above in a way because, before approving the changes to the table, I update the existing values in the table of the C column so I would not get unique constraint error.

    When you click the button Save, I get a constraint exception. Hope I made my requirement clear.

    Can someone give me a clue to this implementation.

    Thank you

    malandain

    With this update, all your C-columnvalue became negative. When you post the form thereafter, forms update agaion records one by one the new positive figures. Because the numbers of 'old' in the db are now negative, there will be no violation-UK.

  • Unique constraint during the race error collecting statistics of schema

    Hello
    I get this error periodically during execution to collect statistics of schema
    In GATHER_SCHEMA_STATS , schema_name= ALL percent= 40 degree = 8 internal_flag= NOBACKUP
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    Unable to correctly update the history table - fnd_stats_hist.
    -1 - ORA-00001: unique constraint (APPLSYS.FND_STATS_HIST_U1) violated
    I went thru notes 470556.1 , but I have not applied patch 5876047 according to the note.

    I can truncate table FND_STATS_HIST? Is it safe to truncate this table?

    Thank you
    ARS

    Published by: user7640966 on January 2, 2011 23:58

    Hi Ars;

    If I suggest his prod, make sure you have a valid backup of your system and also raise sr and confirm with oracle support. If you are on the clone or test, such as mention of doc first to backup table FND_STATS_HIST (make sure that you have a valid backup), truncate and repeat the test question

    Respect of
    HELIOS

  • a unique index or unique constraint on the issue of view Matt

    10.2.0.3

    I have an OLTP table and a matte view to fast refresh of the table in the warehouse. I have unique indexes on the matte view just as I have on the OLTP table. Of course, it's a bad idea because the updating Oracle on mattress views mechanism does not apply to the dml in the same order that it occurred on the side of OLTP? Should I get rid of all the unique indexes on views mattress in my warehouse and create regular index because of their unique nature will just happen because the side OLTP has a unique index? What will be the impact on the performance of the queries? Here's the alert log...

    Journal of owp2 alerts
    =======================
    ORA-12012: error on auto work 1595
    ORA-12008: error path refresh materialized view
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 510
    ORA-06512: at line 1
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-00610: internal error Code
    ORA-12012: error on auto work 260282
    ORA-30439: updating of the ' ORA-30439: updating of the 'SMS_AR MV_ROUTE_REF_MRKR' failed due to the ORA-12008: error in the path of refresh materialized view
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2254
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2460
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2429
    ORA-06512: at "SMS_AR.PA_PIES_WAREHOUSE", line 44
    ORA-06512: at line 2
    ORA-20000: index 'SMS_AR '. "' I01_MV_PIES_INV_REFMKR ' or the partition of this index is unusable

    Mark Reichman wrote:
    I think that this problem is resolved... Unless someone has something else to add. I have not tried yet... But it seems to be valid. I did a test and a unique constraint can be delayed in fact creates a non-unique index. So I need to remove my unique index on my matte view and create unique constraints can be delayed.

    Or...

    forget the unqiue part and simply change the indexes not unique because the main table has a unique index and guarantees uniqueness for me and the matte view will simply copy whats in the main table.

    Mark,

    the solution seems reasonable. Just a note: If you use a "reportable" unique constraint Oracle ignores any attempt to perform a direct-path insert of access and still stations conventional insert generating undo and many more again.

    As long as you do only a 'rapid' refresh, it should not matter, but in case you deal with refreshs full large MVs, this could make a difference when running not atomic refreshs (who can take advantage of the direct-path inserts / DML etc. at the same time)...

    Then you can consider using only non-unique index rather than the constraint may be delayed if performance can matter and given the fact that you should never see duplicates in the MV because of the constraint on the base table.

    Furthermore, you can use a non-unique index to apply a not reportable unique/primary key constraint as well, it is supported. You just need to create the index yourself before you set the constraint or using explicit syntax "CREATE INDEX" of the constraint clause.

    For more information, I wrote a note on this problem "may be deferred" some time ago:

    http://Oracle-Randolf.blogspot.com/2008/07/Deferrable-constraints-and-direct-path.html

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • the value of pan and zoom of the time constraints?

    PE10 using - I have a photo image that is attached to a total (hold time) that I want, I want add pan and zoom effects to it with back change the span of the image on the timeline. Is there a way to tell the first elements to force the pan aggregtate and unavailability zoom times not to go beyond the original image?

    To clarify, I had an image that held for the correct duration, but when I was sleeping w/pan and zoom, I found that I had extended the duration of the image, while it was now about 5 times longer that it should have been, and he threw all my other pictures to the bottom of the timeline. I like to keep the fixed duration without having to pull out my calculator and stopwatch.

    Thank you (just learning this...)

    calpolyjeff wrote:

    When I was sleeping w/pan and zoom, I found that I had extended the duration of the image, while it was now about 5 times longer that it should have been

    You must watch the landmarks of Pan & Zoom tool in the image and changes with the timeline when working in the tool. As you add / move / delete your frames you will change the elements of duration - the time to hold and the Pan.

    In the example below, my time to Pan between part one and part two is sixteen seconds. You can change this by clicking on the time of pan and enter a duration. The other times I've highlighted is is the second a downtime for two framework. Again you can change it by clicking on it. You can also see the time to stand for a framework to the second five point on the timeline itself.

    Hope this helps,

    See you soon,.

    --

    Neale

    Insanity is hereditary, get you your children

  • Need help with a self-join select the parent and child

    Hi all

    I have an OFFICE table that will hold the Oncology, district and division of the hierarchic is Oncology-district-> division >

    I want to list Oncology, district and division with its parent of the value of the following
    provinc     district      division
    
    A            NULL       NULL
    A            A.A         NULL
    A            A.A         A.A.A 
    -- Create table
    CREATE TABLE OFFICE
    (
      SLNO         VARCHAR2(20 BYTE),
      OFFICE_NAME  VARCHAR2(20 BYTE),
      PARENT_SLNO  VARCHAR2(20 BYTE),
      TYPE         VARCHAR2(2 BYTE)
    );
    
    ALTER TABLE OFFICE ADD (
      CONSTRAINT OFFICE_PK
      PRIMARY KEY
      (SLNO)
     );
    
    ALTER TABLE OFFICE ADD (
      CONSTRAINT P_C_FK 
      FOREIGN KEY (PARENT_SLNO) 
      REFERENCES OFFICE (SLNO));
    
    
    INSERT INTO OFFICE
      (SLNO, OFFICE_NAME, PARENT_SLNO, TYPE)
    VALUES
      ('1', 'A', NULL, 'PR');
    INSERT INTO OFFICE
      (SLNO, OFFICE_NAME, PARENT_SLNO, TYPE)
    VALUES
      ('2', 'A.A','1', 'DT');  
    INSERT INTO OFFICE
      (SLNO, OFFICE_NAME, PARENT_SLNO, TYPE)
    VALUES
      ('3', 'A.A.A', '2', 'DV');  
    I need your help.
    Thank you.

    Published by: Dipabkar Banik (DB) on June 13, 2011 12:17 AM

    Published by: Dipabkar Banik (DB) on June 13, 2011 12:18 AM

    Published by: Dipabkar Banik (DB) on June 13, 2011 06:45

    Published by: Dipabkar Banik (DB) on June 13, 2011 06:47

    Try this

    SELECT   CONNECT_BY_ROOT (office_name) provinc,
                 DECODE (LEVEL, 2, office_name, PRIOR office_name) district,
                 DECODE (LEVEL, 3, office_name) division
          FROM   office
    CONNECT BY   PRIOR slno = parent_slno
    START WITH   parent_slno IS NULL
    

Maybe you are looking for