parent ID column in the outbreak of the child

Hello

It's Jean Philippe

I use a sequence to generate the primary key column in the table emp

but I continue in this mode for n1.dept_id | Seq.nextval in emp_id

(IE dept_id + sequence becomes the employee id)

and I also, child table

in the child table that I need to insert this manually generated emp_id in emp_id (referenced column) child table

How to insert

Please let me know

Thank you

You could use the RETURNING clause on your insert statement to get the value that the trigger is created and then use this value in your child table for example inserts

SQL > create table emp_parent (ID, ename varchar2 (50), number of deptno)
2.

Table created.

SQL > create table emp_child (ID number, emp_parent_id number, varchar2 (50)) txt
2.

Table created.

SQL > create sequence generic_sequence
2.

Order of creation.

SQL > create trigger TrgEmpChild before insert on emp_child
2 for each line
3. start
4: new.id: = generic_sequence.nextval;
5 end;
6.

Trigger created.

SQL > create trigger TrgEmpParent before insert on emp_parent
2 for each line
3. start
4: new.id: = (: new.deptno * 10000) + generic_sequence.nextval;
5 end;
6.

Trigger created.

SQL > declare
2 number of EmpParentId;
3. start
4 insert into emp_parent (ename, deptno)
5 values ('Fred', 10)
6 return id in EmpParentId;
7 insert into emp_child (emp_parent_id, txt)
8 values (EmpParentId, ' Some child Text ');
9 validation;
10 end;
11.

PL/SQL procedure successfully completed.

SQL > select * from emp_parent;

ID ENAME, DEPTNO
---------- -------------------------------------------------- ----------
100001 Fred                                                       10

SQL > select * from emp_child;

ID EMP_PARENT_ID TXT
---------- ------------- --------------------------------------------------
2 100001 certain child text

Tags: Database

Similar Questions

  • Virtual disk parent has changed since the child was created.

    I recently had one of my virtual machines go down and I couldn't connect to access anything whatsoever, so I rode as an extra hard drive to another virtual machine in order to access the data I needed.

    Once I had finished I he took off the other VM and proceeds to the power on the virtual machine, but I got an error of:

    "The virtual disk parent has been changed since the child was created." The content of the virtual disk ID parent does not match the ID of parent matching the child content. »

    Reason: The virtual disk parent has changed since the child was created. The content of the virtual disk ID parent does not match the ID of parent matching the child content.
    Cannot open disk ' / vmfs/volumes/4e24c6fe-3c2ad61e-a57c-e4115bbbce6c/SNCTrillium/SNCTrillium-000003.vmdk' or one of the snapshot disks it depends on.

    I read upward through the knowledge base of VMWare on the modified files, but I've never had to do that before and I'm not sure about how to go on this subject as I've never used the vsphere CLI either.

    I am currently using ESXi 5.0.0 with vsphere client 5.0.0. I've attached a screenshot of the error.

    According to the snapshot between SNCTrillium - 000001.vmdk and the basic disk SNCTrillium.vmdk is broken, which means that the basic disk has been changed. I have attached an instant replacement for the SNCTrillium - 000001.vmdk with a fixed string that should allow you to open the virtual machine. However, since I do not know what and how much data has changed on the basic disk, I can't tell you how much data corruption, you will see. So you better take an another snapshot to be temporary once loading hard file attached, in order to ensure the current hard data files cannot be changed.

    André

  • The virtual disk parent has changed since the child was created

    Hi all, need your help with this one.

    I deleted two snapshots and now I can not start the virtual machine.

    Get the following error:

    Reason: The virtual disk parent has changed since the child was created.
    Cannot open disk ' / vmfs/volumes/4c483d34-a8c778c4-46a5-001cc460f09e/WEBPDXXXY/WEBPDXXXY_1-000003.vmdk' or one of the snapshot disks it depends on.

    I tried that link but still did not work KB: http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC & docType = kc & docTypeID = DT_KB_1_1 & externalId = 1007969

    I can still see the WEBPDXXXY_1 - 000003.vmdk, WEBPDXXXY_1 - 000002.vmdk and WEBPDXXXY_1 - 000001.vmdk when I browse the data store.

    WEBPDXXXY_1 - 000003.vmdk

    # Disk DescriptorFile
    version = 1
    Encoding = 'UTF-8 '.
    CID = 59fab513
    parentCID = a4a63bd5
    isNativeSnapshot = 'no '.
    createType = "vmfsSparse."
    parentFileNameHint = "WEBPDXXXY_1 - 000002.vmdk".
    # Description of the measure
    RW 157286400 VMFSSPARSE ' WEBPDWEBPDXXXY_1-000003 - delta.vmdk.

    # The database disk
    #DDB

    WEBPDXXXY_1 - 000002.vmdk
    # Disk DescriptorFile
    version = 1
    Encoding = 'UTF-8 '.
    CID = a4a63bd5
    parentCID = 0f8995f3
    isNativeSnapshot = 'no '.
    createType = "vmfsSparse."
    parentFileNameHint = "WEBPDXXXY_1 - 000001.vmdk".
    # Description of the measure
    RW 157286400 VMFSSPARSE ' WEBPDXXXY_1-000002 - delta.vmdk.

    # The database disk
    #DDB

    DDB. Deletable = 'true '.
    ddb.longContentID = "ab1b7008e386c884ae920930a4a63bd5".

    WEBPDXXXY_1 - 000001.vmdk

    # Disk DescriptorFile
    version = 1
    Encoding = 'UTF-8 '.
    CID = 0f8995f3
    parentCID = 926f96fa
    isNativeSnapshot = 'no '.
    createType = "vmfsSparse."
    parentFileNameHint = "WEBPDXXXY_1.vmdk".
    # Description of the measure
    RW 157286400 VMFSSPARSE ' WEBPDXXXY_1-000001 - delta.vmdk.

    # The database disk
    #DDB

    ddb.longContentID = "0336846d9f849b4b97ad028f0f8995f3".
    DDB. Deletable = 'true '.

    WEBPDXXXY_1.VMDK

    # Disk DescriptorFile
    version = 1
    Encoding = 'UTF-8 '.

    CID = 926f96fa

    parentCID = ffffffff
    isNativeSnapshot = 'no '.
    createType = "vmfsRawDeviceMap."

    # Description of the measure
    RW 209715200 VMFSRDM ' WEBPDXXXY_1 - rdm.vmdk '.

    # The database disk
    #DDB

    ddb.toolsVersion = "8295.
    ddb.adapterType = "free".
    DDB. Geometry.sectors = "63".
    DDB. Geometry.Heads = "255".
    DDB. Geometry.Cylinders = "13054.
    DDB. UUID = "60 00 C2 92 41 62 5 d 8f-10 59 12 60 53 0 to a8 94.
    ddb.longContentID = "b204c5bc523bbc83c01dd3ed926f96fa".
    ddb.virtualHWVersion = "7".
    DDB. Deletable = 'true '.

    Is there a chance to run ls-lisa from the command line (SSH) in the virtual machine folder and provide the output!

    I ask because I'm a little worried about the timestamp of the hard (May 2011). Depending on the size of the files in the snapshot, it seems that the second virtual disk is not really used by the guest operating system and we could come back manually (by editing the .vmx file) on the resized basic disk (100 GB compared to 75 GB for snapshots) without losing important data!

    If you want to revert manually,

    • delete the virtual machine of the inventory
    • backup and then edit the .vmx file (replace "WEBPDMAPPD_1 - 000003.vmdk" with "WEBPDMAPPD_1.vmdk")
    • Move 3 snapshots in a directory temporary sub
    • Add the virtual machine to inventory
    • create a new snapshot to prevent the current hard files to be modified
    • Turn on the virtual machine

    If everything works as expected, you can delete the snapshot files moved and remove the snapshot created in the Snapshot Manager again.

    André

  • Instant restore: the virtual disk parent has changed since the child has been created

    Buenos dias,

    A worm if someone is ha sown con este problema y me can echar UN cable.

    Al trabajar con una maquina virtual en local con el disco en un disco external depuradora, to me broken instant crear of the United Nations (por el disco local creo en lo disgrace).

    Al use esta Máquina in casa, arranco perfectly, claro, pero sin los datos del snapshot.

    Hoy al arrancarla in the oficina ha generated a conflict: "the virtual disk parent has changed, since the child was creates," ha detectado what ha modified the virtual machine after ultima grabación del snapshot, no permite arrancarla.

    Could eliminando el solucionarlo snapshot, pero no puedo perder todo lo as he ido generating information.

    Alguna idea?

    Para eso estamos DiegoPS.

    No olvides close the discusion marcandola como respondida.

    Saludos,

  • repair broken CID-String > the virtual disk parent has changed since the child was created.

    Hello

    We have ESX 3.5 Update2

    During the withdrawal of one of the many snapshots, the process has been crushed and the CID string seems to be corrupted.

    Now the last work of x file - 000006.vmdk cannot start because the file is based on x - 000004.vmdk.

    Now, I get this message:

    Cannot open disk /vmfs/volumes...x-000007.vmdk or one of the Flash disk that it depends on.

    Reason: The virtual disk parent has changed since the child was created.

    If you provide vmdk small text files, all the vmware.logs, the vmsd file and the vmx file I can look into it

    ___________________________________

    VMX-settings- WS FAQ -[MOAcd | http://sanbarrow.com/moa241.html]- VMDK-manual

  • Where can I configure the rule of naming for the columns of the child?

    I have the logic model below:

    https://www.dropbox.com/s/1eux01rrkmcn84f/child_logical.PNG

    When I have the engineer I get the following physical model:

    https://www.dropbox.com/s/pwl2zxkvuigdr5q/child_physical.PNG

    How can I configure that no entity name prefix must be added to the name column?

    Columns must be named create_ts, modify_ts, delete_ts and attribute_1. (upcase all is ok).

    I tried to change the model of standard naming for attribute relationships, but it has no effect.

    Can someone give me a hint?

    I found a way to resolve names with a custom transformation script.

    ceving: abuse of inheritance for the coating with SQL Developer

    But the behavior of the new Modeler data seems to be different from the old. I create a model with the old. And now I'm still working on the model by the new. And for some columns, not the name of the inserted table and other tables. This occurs in the same model. I think that there still is some sort of bug in the problem.

  • Help, please! Snapshot after expand VM, virtual disk parent has changed since the child was created

    OK, here's the situation, (maybe you can find a lot of discussion on this one)

    I have a vmware server running SuSE Linux Enterprise Server 10. I use as its host vmware ESX 3.0.1.

    I realize that I need to extend the drive because he must have more space disk for the production server. Then I resize the disk using vmkfstools x 90 G TARANTELA - TEST.vmdk. The bad news is, I didn't know that the server has a snapshot on VI client. As you know, the error occurred:

    Failed to open the disc

    "/ vmfs/volumes/4652e777-3eb2a038-8fce-0019bb343796/TARANTELLA-TEST-000007.vmdk" or one of the snapshot disks it depends on.

    Reason: The virtual disk parent has been changed since the child was created

    Then I remove the snapshot of the VI client and re-save the virtual machine to inventory, but it may yet open the disc unless I edited the .vmx line file:

    scsi0:0. FileName = 'TARANTELA-TEST - 000007.vmdk '.

    TO

    scsi0:0. FileName = ' TARANTELA - TEST.vmdk.

    It runs as the first time I installed the system, but all the important configuration is in 'TARANTELA-TEST - 000007.vmdk' snapshot.

    Someone there the sollution, how can I do my work of snapshot again?

    Kind regards

    Arfal

    In SL32-AP-TARANTELA - TEST2.vmdk

    change

    CID=dc621992
    

    TO

    CID=ce700012
    

    and

    RW 188743680 VMFS "SL32-AP-TARANTELA-TEST2-flat.vmdk"
    

    TO

    RW 31457280 VMFS "SL32-AP-TARANTELA-TEST2-flat.vmdk"
    

    and

    ddb.geometry.cylinders = "11748"
    

    TO

    ddb.geometry.cylinders = "1958"
    

    in SL32-AP-TARANTELA-TEST2 - 000007.vmdk

    change

    RW 188743680 VMFSSPARSE "SL32-AP-TARANTELA-TEST2-000007-delta.vmdk"
    

    TO

    RW 31457280 VMFSSPARSE "SL32-AP-TARANTELA-TEST2-000007-delta.vmdk"
    

    And then you change the changes you have made to the VMX file.

    Try power o the VM - you will get probably mistakes (inside the virtual machine).

    If this works report back (we are not yet made).

  • Parent.removeChild (child) is not updated Parent width/height when the child was shot

    No idea why this is happening? I've been struggling with this during three hours now: - (.)

    I had a Parent Sprite, call SpriteP, which held inside two other Sprites. Sprite1 and Sprite2.

    When Sprite2 turned:

    trace (SpriteP.width + ' ' + SpriteP.height); 100 250.

    SpriteP.removeChild (Sprite2)

    trace (SpriteP.width + ' ' + SpriteP.height); 100 200. -> works, 200 is good.

    When Sprite2 is turned to 90:

    trace (SpriteP.width + ' ' + SpriteP.height); 100 300. -> 300 because Sprite2 is turned.
    SpriteP.removeChild (Sprite2)
    trace (SpriteP.width + ' ' + SpriteP.height); 100 300. --> even if I just removed Sprite2!

    Sprite2 is a rectangle. When I turn, of course, the height of its parent company, SpriteP, is GROWING. But I expect this height to go back to what it should be when I remove Sprite2!

    And it does! If I remove Sprite2 while DO NOT tour, the height of the parent falls back to normal, 200. But if I rotate Sprite2, the Parent does not update its limits: - (.)

    This is important because your explanation makes no sense.  If I don't understand what you're doing, I can't help you.

    and, I think, if you can't explain what you're doing, you do not understand what you are doing and this is why you do not understand the results of your tracing instructions.

    I could be wrong.  Maybe it's that you have discovered a bug in flash.  but it's very unliklely because I have not seen this problem before and I probably have more experience with flash 'issues' that the majority of experts flash (because of my activity in the adobe forums).

    What would help, is to take a screenshot which shows your 3 sprites, unrotated and etiquette and another screenshot rotated, both until Sprite2 is deleted.

  • SQL to align the values of the child with the parent columns

    Hello world

    I'm stumped on how to develop a sql query that generates a report which my child values are aligned with my columns parent based on corresponding years.  Here is an example...

    create table test_yr (yr_id number primary key, yr_nb number);
    insert into test_yr values (1,2013);
    insert into test_yr values (2,2014);
    insert into test_yr values (3,2015);
    
    create table test_parent (parent_id number primary key, parent_yr_id_begin number, parent_title varchar2(100));
    alter table test_parent add foreign key (parent_yr_id_begin) refererences test_yr (yr_id);
    insert into test_parent values (1,1,'This rec starts in 2013');
    
    create table test_child (
         child_id number primary key,
         child_parent_id number,
         child_yr_id_begin number,
         child_title varchar2(100),
         child_yr1_val number, child_yr2_val number, child_yr3_val number, child_yr4_val number, child_yr5_val number
    );
    alter table test_child add foreign key (child_parent_id) references test_parent (parent_id);
    alter table test_child add foreign key (child_yr_id_begin) references test_yr (yr_id);
    insert into test_child values (1,1,3,'This rec starts in 2015',10,20,30,40,50);
    insert into test_child values (2,1,3,'This rec starts in 2015',15,25,35,45,55);
    
    
    

    The child can begin to another to start the year as the parent, which makes different yr1 for parent and yr1 for child.  So, for this example, the child 1 year (2015) = year 3 of the parent.

    I can get the values strictly of the child using the following...

    select child_yr1_val, child_yr2_val, child_yr3_val, child_yr4_val, child_yr5_val
    from test_child
    where child_parent_id = 1;
    
    

    However, I need the report to be based on the first five years of the parent.  And since the child does not start until 2015, two years should be zero.  This is the expected result:

    Yr1 | YR2 | YR3 | yr4 | Yr5

    ---------------------------

    0   | 0   | 10. 20. 30

    0   | 0   | 15. 25. 35

    I am doing it using simple sql without having to use pl/SQL to derive a dynamic query.  But I need to somehow to the height and line up the years... like in this example, yr1 (child) = yr3 (parent), (child) yr2 = yr4 (parent), etc..  I hope that some joints and case statements will do the trick, but I don't know how to use them to get the result that I need.  Can anyone help?  Oracle 11 g 2.

    Thank you

    Mark

    Hi, Mark,.

    Here's one way:

    WITH unpivoted_child AS

    (

    SELECT child_id, child_parent_id

    child_yr_id_begin + child_yr - 1 AS column_num

    val

    OF test_child

    UNPIVOT (val

    FOR child_yr (child_yr1_val AS 1

    child_yr2_val AS 2

    child_yr3_val AS 3

    child_yr4_val AS 4

    child_yr5_val AS 5

    )

    )

    WHERE child_parent_id = 1

    )

    SELECT NVL (y1, 0) AS yr1

    , NVL (y2, 0) AS yr2

    , NVL (y3, 0) AS an3

    , NVL (y4, 0) AS yr4

    , NVL (y5, 0) AS yr5

    Of unpivoted_child

    PIVOT (SUM (val)

    FOR column_num IN (1 AS y1

    2 AS y2

    3 AS y3

    4 AS y4

    5 AS y5

    )

    )

    ORDER BY child_parent_id

    child_id

    ;

    Have 5 columns in the test_child that all say the same thing, obly for different years, isn't a very good design table.  It wouyld be better to have a single table for all the attriburtes that apply to the child and another table for each combination of year, with a single amount on each line.  Because you don't have that, the unpivoted_child of the subquery, it essentially creates on the fly.

  • Apple: Can allow you parents more control over the access of children iTunes?

    Parental restrictions on mini iPad 16 GB of my granddaughter running iOS 9.3.5 (original version) do not seem to allow parents to control properly the child access iTunes. We have music, news and Podcasts (iTunes), reserved for the 'Clean' as opposed to 'Explicit', but he is always happy that we find unacceptable.

    Apple or someone you suggest a way to further control access of the child to the iTunes app?

    If not, then... Apple - there must be a way to create a framework between Clean and Explicit. You please solve this problem?

    There are other parents who have the same problem?

    Thanks for your thoughts / feedback.

    Apple isn't here.

    This is a support forum user community product technique.

    Aside from Apple employees who are specialist community technical and support the community moderators, we are all users here, just like you.

    If you want to leave a comment on the ability of your iPad to have parental controls more complete, leave your comments here.

    http://www.Apple.com/feedback/iPad.html

    Good luck!

  • Breakdown of data into essbase parent to the child member

    Hi all

    Is it possible to assign the Parent Member data to the child member not to mention all the dimension members in the calc using the essbase calc functions.


    I have a dimension of Prog which have many members, as shown below. And I want to assign the value of the parent model new Jeep WK Transmission Member produced A4-45RFE 2005
    (Lev 1) to the child member 2005 WK Transmission new model product A4-45RFE Jeep_FCST (Lev 0) similar to the parent member option, but with a suffix "_FCST".


    Lev1 WK - 2005 new Transmission product model A4-45RFE Jeep
    Lev 0 - 1211 - 2002-1052
    Lev 0 - WK 2005 model new Transmission product A4-45RFE Jeep_FCST

    Any help will be appreciated.

    Thank you
    Sri

    Hello

    After my above idea I'll try:

    DIFFICULTY)
    "2010-01-01": "2010-12-31",
    "MYCOMP US Load."
    'Mfg Assmt College',
    @MATCH (, "FCST_ *"))

    'Current' = 'Current'-> @PARENT ()-> "MYCOMP US"-> "Mfg College;

    ENDFIX

  • Records in the Child Table to return DBAT connector deletion and addition

    I'm trying to add a record of the child to a resource DBAT (11.1.1.5). The structure of the Table is set up like this:

    OIM_USR

    Usr_key First name Last_name

    OIM_ROLE

    USR_KEY ROLE_KEY

    Where OIM_USR is the parent, and OIM_ROLE is the child that can store multiple values per user.  The problem arises when there is already an existing value in the child table. Consider the following example for instance

    OIM_USR

    Usr_key First name Last_name
    45JohnDOE

    OIM_ROLE

    USR_KEY ROLE_KEY
    452454
    454453

    If I add another line to the role of the identity UI table Edit tab added resource role, but IOM is remove the previous two lines and then adding them back. We know that it is because the source OIM_ROLE table contains a timestamp of creation triggered update time when a row is added. If I add a line to OIM_ROW then all three are getting updates for a reason any. We can also see the history of resource shows three updates. Inserting a record of the child should not call the process of update tasks. I've attached a screenshot of the history of the resource.

    In addition, I upped the DBAT Connector logs and he showed a trace of remove:

    DELETE FROM OIM_ROLES WHERE OIM_ROLES. USR_KEY =?

    Why he deletes all children lines before an insertion?

    I think you use OOTB DBAT connector without modification. I think that's how its design to add/change/delete files. For child process also updated form, we follow the same approach.

    Are you facing any functional problem in connector DBAT to reach your use cases?

    ~ J

  • How can I get the child to pass under the appropriate parent based on the name?

    I'm reading an .ini file and based on the name of the group, I want that child to go under this name. If I read in another file, and he wears the same group name, that I want the child to be able to go under this name. Right now I can't even the child to pass under a different group name when it is supposed to. He continues to go by the same name of Parent. Here is my code.

    parent of int = 0;

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Group', cbuf, BUFSIZE);

    InsertTreeItem (s_gMainWindow.managerTab, MANAGERTAB_TREE, VAL_SIBLING, 0,)
    VAL_NEXT, cbuf, NULL, 0, relative).

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Name', cbuf, BUFSIZE);
         
    InsertTreeItem (s_gMainWindow.managerTab, MANAGERTAB_TREE, VAL_CHILD, 0,)
    VAL_LAST, cbuf, NULL, 0, relative ++);

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Version', cbuf, BUFSIZE);
         
    SetTreeCellAttribute (s_gMainWindow.managerTab, MANAGERTAB_TREE, relate, 1, ATTR_LABEL_TEXT, cbuf); I can't do this correspond with the child column.

    Try this:

    parent of int = 0;

    int parent, index;

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Group', cbuf, BUFSIZE);

    parent = InsertTreeItem (s_gMainWindow.managerTab, MANAGERTAB_TREE, VAL_SIBLING, 0,)
    VAL_NEXT, cbuf, NULL, 0, relative).

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Name', cbuf, BUFSIZE);
    index = InsertTreeItem (s_gMainWindow.managerTab, MANAGERTAB_TREE, VAL_CHILD, parent,
    VAL_LAST, cbuf, NULL, 0, relative ++);

    Ini_GetStringIntoBuffer (iniText, 'Details', 'Version', cbuf, BUFSIZE);
    SetTreeCellAttribute (s_gMainWindow.managerTab, MANAGERTAB_TREE, index, 1, ATTR_LABEL_TEXT, cbuf);

    the idea is to keep the index of the item that you insert in order to reuse it when you want to edit the item.

  • Hide column of the HFM 11.1.2.3 web form

    Hello

    I'm quite new to HFM and I have what could be a very stupid problem.

    Our requirement is to show on an online form < Parent Curr Total > by entity, a column of eliminations and assets < entity Curr Total >

    Entity 1 Entity 2 Entity n. Eliminations Holding

    As the eliminations are at the basic level and boils down not to the parent company, tried to add each column of elimination of entities to the web form and calculate a column as being the sum of all of the eliminations.

    So much and so much good, but when it comes to hidding columns in entity removal, I simply have not found how. I tried to change the width of the columns of 1px, 1 pt, 0% etc and the column remains with the same width, but IV ' e did the same on the 11.1.1.3 version and it works, kind of weird. I also tried to hide the added display: no and he's hiding the values, the column always shows.

    Summer research everywhere and have not been able to find advice on how to hide the columns, so I would be very happy if somenone could help me.

    Thank you very much for your time,

    See you soon

    Santiago

    Hello. Build the questionnaire to show the children of the parent entity to in the first column, the parent entity to in the third column and the second column as col3 calc less col1.

    Eric

    Eric Erikson, CPA

    Consultant independent HFM

    828-485-8454.

    [email protected]

    www.LinkedIn.com/in/ericerikson

    ericerikson.blogspot.com

  • parents and children of the same table records

    I want to create a query that is a union such that 2nd resultset is based on the game of results 1. I have a table that has parent and child records in the same table.

    Table: EVENTS
    EVENT_ID
    PARENT_EVENT_ID
    CREATED_DATE
    (other columns)

    If PARENT_EVENT_ID is null, then this is a parent record, otherwise it is a book of the child. I want to select all parent records then union them with all the related child records... something like this:

    Select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null - all parents
    Union
    Select * event where PARENT_EVENT_ID in (select EVENT_ID of EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null)-include all children selected from the top parent

    It works but it of kind of ugly, I want to avoid using the subselect in the 2nd because it is a repeat of the 1st statement, is there a way to alias the first statement and only refer to him in the 2nd query?

    Hello

    CONNECTION is very similar to a UNION on the same table. How is this:

    SELECT     *
    FROM     events
    WHERE     created_date     < SYSDATE - 90
    START WITH     parent_event_id     IS NULL
    CONNECT BY     parent_event_id     = PRIOR event_id
         AND     LEVEL          <= 2    -- Maybe
    ;
    

    ?

    To answer your question: Yes, you can still keep the result set of a query and the Treaty as if it were a table or vew, like this:

    WITH     roots     AS
    (
         SELECT     *
         FROM     events
         WHERE     created_date     < SYSDATE - 90
         AND     parent_event_id     IS NULL
    )
    SELECT     *
    FROM     roots
         --
    UNION ALL
            --
    SELECT     *
    FROM     events
    WHERE     created_date     < SYSDATE - 90
    AND     parent_event_id     IN (
                          SELECT  event_id
                          FROM    roots
                      )
    ;
    

    It's always a bit ugly, however. I would use CONNECT BY or from Oracle 11.2, a recursive WITH clause (which is explicitly a UNION), or, in any version, a self-join, like this:

    SELECT     c.*
    FROM          events  c
    LEFT OUTER JOIN     events     p  ON   p.event_id  = c.parent_event_id
    WHERE   p.parent_event_id  IS NULL
    ;
    

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Report where the queriy above (the one you decide to use) is producingthe bad results and explain, using specific examples, how you get the right results from these data in these places.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

Maybe you are looking for

  • During the installation of software, I forgot to uncheck to change my start page and now it goes to hi.ru even though I changed it in Firefox.

    I was installing software. I forgot to uncheck the checkbox change my homepage. I changed it in Firefox and it always happens. The site is hi.ru and not in English. I checked for any new or unusual software in Control Panel and you will see nothing u

  • HP dc7600 sff

    can someone please tell me if a XEON 3050 can be mounted on a HP DC7600 sff. BIOS has been updated with the latest firmware (Bios v 1.60). Thank you

  • Convert a small SSD using PC Restore fuller?

    Can I use complete PC Backup/Restore to convert a disk hard solid state of my office?  The SSD is small (128 GB) than current hd (250GB).  Looks like this answer has been 'No', but I just wanted to confirm that I'm not missing something.  Seems that

  • Noise of Boing

    My PC started doing a "boing" sound every 10 minutes approximately.  It happens even if I quit all programs.  How can I stop?

  • (Not really lively) Using Flash 8

    I downloaded Flash 8 as Animate/CC was not my thing. So when I arrived in Flash 8 I opened and I could not shoot for a reason any. I could draw in CC and Animate so that other programs, including Photoshop. When I try to do a line I can do only one p