Look for the same combination of parent and child

Hi all I am using oracle 10g. can you please help me in this issue.
How can I know if the same combination of filiation in the table

key to value and value are values given by the user.
If the user tries to create a profile even with the same set of key_value and value while avoid
So how do you achieve this.


Profile example already in the table
----------------------------------------------------------------------
-- PROFILE_ID,DETAIL_ID,PARENT_DETAIL_ID,KEY_VALUE, VALUE, LAST_IND
100,               1,               NULL,                      1,              CDE,     N
100,               2,              1,                            2,              XXX,     N
100,               3,              1,                            2,              YYY,    N
100,               4,              1,                            4,              NEW,    Y
new user profile - it should raise an error saying that same profile already present
-- PROFILE_ID,DETAIL_ID,PARENT_DETAIL_ID,KEY_VALUE,VALUE,LAST_IND
101,               5,               NULL,                      1,              CDE,    N
101,               6,              5,                            2,              XXX,    N
101,               7,              5,                            2,              YYY,    N
101,               8,              5,                            4,              NEW,    Y
Published by: DeepakDevarapalli on December 9, 2009 09:48

Published by: DeepakDevarapalli on December 9, 2009 09:59

Hello

Rather than separate subqueries to get target_ptxt and staging_ptxt, it is easier to combine the target and the staging in a UNION, then calculate the ptxt once, unified data. To mark the staging data, I assigned profile - 1, assuming it wasn't a number real profile.

The following query calculates ptxt for each profile, including the profile =-1 (staging).
It then compares the ptxt transit zone to all other ptxts and identifies each one that matches.
If the query does not have all the lines, then staging did not match any profile existing in tagrget.

WITH       union_data     AS
(
     SELECT     profile
     ,     key
     ,     value
     FROM     target
          --
     UNION ALL
             --
     SELECT     -1     AS profile
     ,     key
     ,     value
     FROM     staging
)
,     got_r    AS
(
     SELECT       profile
     ,       key || '/' || value               AS rtxt
     ,       ROW_NUMBER () OVER ( PARTITION BY  profile
                                  ORDER BY         key
                           ,              value
                         )                      AS rnum
     FROM       union_data
)
,     got_p     AS
(
     SELECT     profile
     ,     SYS_CONNECT_BY_PATH (rtxt, ',')     AS ptxt
     FROM     got_r
     WHERE       CONNECT_BY_ISLEAF     = 1
     START WITH     rnum          = 1
     CONNECT BY     rnum          = PRIOR rnum + 1
          AND     profile          = PRIOR profile
)
SELECT    'Profile Already Present'     AS warning
,       t.profile
FROM       got_p          s
JOIN       got_p          t     ON     s.ptxt     = t.ptxt
WHERE       s.profile     =  -1
AND       t.profile     != -1
;

Tags: Database

Similar Questions

  • Look for the same combinations of characters

    Hi guys,.

    We experience this problem to enter a copy of parts inventory in the system who physically refers to the same part. You create a select query to browse the list of parts inventory to discover existing parts with similar names.

    Have a search on a specific set of characters and it must list the records even with 50% of the characters, they entered. Characters can be anywhere in the name of the part with any case.

    For example: entry "abcd1234" must return the parts with the following name...

    A nut 234 R49

    B12 SE A22

    156 65 a2 hub

    But not...

    ABC 89998

    AK-47

    Xbox 360

    K98b Mauser

    Thank you

    Napster

    Crazy, but in any case

    SQL > WITH t AS
    () 2
    3. SELECT "a nut 234 R49" str FROM DUAL
    4 UNION ALL
    5. SELECT "B12 SE A22" DOUBLE
    6 UNION ALL
    7. SELECT 'Hub 156 65 a2' FROM DUAL
    8 UNION ALL
    9. SELECT 'abc 89998' FROM DUAL
    ANY UNION 10
    11. SELECT 'AK 47' FROM DUAL
    12 UNION ALL
    13. SELECT 'Xbox 360' FROM DUAL
    14 UNION ALL
    15 SELECT 'Mauser K98b' DOUBLE
    (16),
    17 input_data
    18 as
    (19)
    20. Select "abcd1234" double input_val
    (21),
    T1 22
    23 as
    (24)
    25 select str
    26, trim (substr (input_val, level, 1)) input_char
    27 t
    28 cross
    29 join input_data
    30 connect by level<=>
    31 and prior str = str
    sys_guid() 32 and prior is not null
    33)
    34 select distinct str
    35, round (percnt, 2) match_percnt
    36, case when round (percnt, 2) > = 50, then "MATCH" else "DOES NOT EQUAL" end status
    37 in)
    38 select t1.str
    39, t1.input_char
    40, t2.str_char
    41, count (input_char) on input_char_cnt (t1.str score)
    42, count (str_char) on str_char_cnt (t1.str score)
    43, (count (str_char) on (t1.str score) count (input_char) more (t1.str score)) * 100 percnt
    44 of the t1
    45 on the left
    Join 46)
    47 select str
    48, trim (substr (str, level, 1)) str_char
    49 t
    50 connect
    51 by level<=>
    52 and prior str = str
    53 and prior sys_guid() is not null
    54                   ) t2
    55 on t1.str = t2.str
    56 and lower (t1.input_char) = lower (t2.str_char)
    order of 57
    58 by t1.str
    59         )
    Order 60
    61 by match_percnt desc
    62.

    STR MATCH_PERCNT STATUS
    ---------------- ------------ ---------
    A22 B12 SE MATCH 60
    a 234 R49 55.56 GAME nut
    156 65 a2 50 GAME hub
    ABC 89998 37.5 does NOT match
    AK 47 25 DOES NOT MATCH


    K98b Mauser 25 does NOT match
    Xbox 360 25 does NOT match

    7 selected lines.

    SQL >

  • you are looking for the same contact again and again

    Hello.

    Sorry if I missed something so trivial that could invalidate this question, but - well I missed it.

    My application constantly seeking the same Contact in the contacts list.

    Is there a better way to find a contact-> o (1) than to go thorugh the entire list-> o (n)?

    A kind of index? or a search option advanced that I supervised?

    I usually add a contact and after some time, I need to access once more.

    Sometimes it is in the same application runs, it is not

    Thank you

    The method described in the thread you cite is the recommended approach.

    With regard to the adequacy between the last phone number, you can search based on the last 4 digits and then perform a string match more in detail of the results in your application.

  • What I can (and if so, how could I) connect two encoders (a linear and angular) for the same chassis (NI 9401) and get their respective MAX OR tasks as simultaneously as possible?

    Sorry, but I'm still pretty new to LabVIEW and NI MAX I plugged the two devices (a linear probe and an angular encoder) for my NI 9401 chassis. I figured out how to create tasks for each and continuous readings of samples of each. Trying to run both in LabVIEW, I get the error message saying that I can't run several tasks at once. He suggests the control task VI, but I did not see any help. Any advice?

    Here is some general information, whatever it's worth: two encoders work the same clock source, PFI4, which, to my knowledge, is the CTR 1 A, where the the angular encoder signal is wired in. Physical channel linear is ctr0 and the angular is ctr1.

    Thank you very much for taking the time to review this issue and help me out!


  • I'm looking for the Mac key combination which is equivalent to Alt + Tab in Windows that allows you to choose Open Windows (toggle).

    I'm looking for the Mac key combination which is equivalent to Alt + Tab in Windows that allows you to choose Open Windows (pass) but I can't find this info.  I hope that someone will tell me what combination of keys and as a bonus, where I can find it in the menu help. Thank you!

    The standard keyboard shortcuts are listed here:

    Keyboard shortcuts in Mac - Apple Support

    You can also define your own in System Preferences > keyboard

  • Sometimes a web page is displayed with only text and no picures. It is not always the same site and is not always the case. If I'm going to explore for the same website that always works

    Sometimes a web page is displayed with only text and no picures. It is not always the same site and is not always the case. If I'm going to explore for the same website that always works

    Hello

    Also try a Ctrl + F5 refresh. This allows to bring the content of the page again.

  • Please help I'm looking for the dowload 10.10 update my dads computer and I can not find it! Does anyone know where could it have?

    Please help I'm looking for the dowload 10.10 update my dads computer and I can not find it! Does anyone know where could it have?

    10.10 is no longer available unless you had previously downloaded. In this case, it would be in the purchase of the Mac App Store section. Its not available for direct plus download.

    You can directly update 10.11 El Capitan.

  • Permission of files and folders for the same user on multiple computers

    Is it possible to set permissions files and folders different for the same user when he connect on different computers in the same domain?

    Example:

    There is a folder named "Folder1".
    When "User1" enter this folder by "Computer1" must have "Read & Execute" permission
    When "User1" enter this folder in "Computer2" must have permission 'change '.

    Thank you

    Hello

    Your question is beyond the scope of this community.

    Please post your question on the TechNet forums:

    https://social.technet.Microsoft.com/forums/Windows/en-us/home

    Kind regards

  • Windows Media Player does not open and I'm not find 'Turn windows features turn on or off' when I'm looking for the beginning. I need quick help.

    Windows media player not open yet

    Regarding "I'm not find 'Turn windows features turn on or off' when I'm looking for the start." ...

    Start > Control Panel > column to the left, choose Classic view > programs and features > column to the left, you will see turn windows features turn on or off the option. For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • SONY TV TAV - L1 AND WHEN I TRIED TO EJECT THE DVD SCREEN LOCKED. NOW I'M STUCK FOR THE SAME MOVIE. W

    I HAVE A TV SONY TAV - L1 AND WHEN I TRIED TO EJECT DVD YESTERDAY IT SHOWS LOCKED AND IT WILL NOT EJECT. NOW I'M STUCK FOR THE SAME MOVIE. WHAT CAN I DO? IT IS NOT IN LOCK FOR CHILDREN MODE

    Hello Dimitra,

    I apologize for the inconvenience, it seems that the drawer has been locked inadvertently.  Please perform the following steps to unlock.

    1. press the power button to turn the monitor of the device.

    2 tap the input selection button to select "DVD".

    3. press and hold simultaneously the button stop and eject until 'UNLOCKED' appears on the front panel.

  • I'm looking for the best way and the best way to get a product key for my windows 7 Edition family.

    Hello.  I'm looking for the best way and the best way to get a product key for my windows 7 Edition family.  Thanks Bob

    Original title: product windows keys 7

    The cheapest option is the OEM System Builder for Windows 7 Home Premium license, but has some license restrictions:

    Amazon.com: Windows 7 Home Premium 64 - Bit System Builder...

    The OEM of Windows 7 versions are identical to the versions commercial full license with the following exception:

    -OEM versions don't offer any free direct support from Microsoft technical support Microsoft

    -OEM Licenses are tied to the computer first you install and activate it on

    -OEM versions allow all hardware upgrades except for an upgrade to a different model motherboard

    -OEM versions does not move directly from an older Windows operating system

    What is OEM software? :
    http://support.Microsoft.com/GP/oemsupport_1/en-GB

    Licensing FAQ:
    http://www.Microsoft.com/OEM/en/licensing/sblicensing/pages/licensing_faq.aspx

    OR

    A detail that does not have these restrictions:

    Where can I still get Windows 7?

    Full version - Microsoft Windows 7 Home Premium

    Version upgrade - Microsoft Windows 7 Home Premium Upgrade

    Family Pack: Upgrade of Microsoft Windows 7 Home Premium Family Pack (3 users)

  • Is possible let activate domain multi UCS VM - FEX and sign up for the same vCenter

    Hi Experts,

    We have 7 domain UCS. But only a vCenter. Now, we want to enable VM - FEX on each UCS area and sign up for the same vCenter. Is - it work? I have found no description limit configuration on this relationship.

    Or we create 7 vCenter for each UCS area? (But I think it's not sense.)

    Best regards
    Meng-Yuan Hsieh (Nick)

    Hi Moua!

    I open a TAC case on that, and after that many discussions with Cisco, connecting several areas a single vCenter UCS is supported.  However, it turns out that Cisco failed to document this and how to make it work.  You will find that the procedures were written in old documentation for VN-LINK and others for VM - FEX.  This documentation shows that it is necessary to create new certificates, and it must match the key to expansion.  This is NOT true nor with the new versions of UCSM and vCenter.  Cisco, said they will update their documentation.

    Here are the steps that we took to connect two UCS areas for the same vCenter using default self-signed certificates.  I hope this helps...  Please mark this message as the right answer when you get a chance.  Thank you!!

    vCenter Version: 5.5

    UCSM Version: 2.2(5a)

    1. On the VM in UCS Manager tab, click VMware.
    2. Set up a key of the unique extension for every area of UCS.
    3. Click on "Configure VMware integration" on each area of UCS and export expansion of local storage.
    4. Install each UCS domain extensions in vCenter.
    5. After you install the extensions, back to UCSM and click Next where you left off in configure integration with VMware
    6. Run the wizard and after that it's over, areas of the UCS should now be connected to the vCenter.

  • External hard drive not a letter from reader: I already installed device driver for the same thing and it's showing in disk management.

    External hard drive not a letter from reader: I already installed device driver for the same thing and it's showing in disk management. But when I checked in system information, it is also displayed device but sectors and the tracs where showing the value 0.

    Hello Sharan,

    These links may help:

    http://TechNet.Microsoft.com/en-us/library/cc750198.aspx

    http://TechNet.Microsoft.com/en-us/library/cc977219.aspx

  • Mismatch in number of index n/b dba_segments and dba_indexes for the same user in the database.

    Hi all

    I had incompatibility number n/b dba_indexes and dba_segments index. Please find the details below.

    SQL > select SEGMENT_TYPE, count (*) from dba_segments where owner = group 'VIM_SCH01' of SEGMENT_TYPE.

    LOBINDEX 11

    LOBSEGMENT 11

    TABLE 68

    INDEX 52-> I see 52 index are here

    SQL > select count (*) from dba_indexes where owner = 'VIM_SCH01 ';  --> See 63 index here for the same user in dba_indexes

    63

    SQL > select count (*) from dba_tables where owner = "VIM_SCH01"; -> showing the same number of tables from dba_segments

    68

    Why it's showing the different number for the index.

    Thank you

    Bhavani.

    No doubt, because your LOBINDEX 11 segments are has index in DBA_INDEXES.  You have 52 index and 11 LOB for a total of 63.  Corresponds to DBA_INDEXES entries.

    You can validate the fact that.  Run something like

    SELECT index_name FROM dba_indexes WHERE owner = 'VIM_SCH01'
    MINUS
    SELECT segment_name FROM dba_segments WHERE  owner = 'VIM_SCH01' and segment_type = 'INDEX'
    

    Which will return 11 index names in DBA_INDEXES but not in DBA_SEGMENTS with a segment_type of the INDEX.  If you compare these indices against the 11 sectors LOBINDEX, I expect you to see them at the height.

    Justin

  • I rented the room light $5 9.99 per month.  Can I also get access to Photoshop for the same rental?   In my previous cat (0216813226), I said yes and gave a link to download Photoshop.  I let it run all night and it never down loaded even if

    I rented the room light $5 9.99 per month.  Can I also get access to Photoshop for the same rental?   In my previous cat (0216813226), I said yes and gave a link to download Photoshop.  I let it run all night and it never down load even though it says 'download now '.

    Hi dave04079,

    Yes, you also get access to install Photoshop on your computer when a member of the creative cloud.

    So I recommend that you please complete the creative process (Windows) Task Manager Cloud and activity monitor (MAC) and then reopen creative cloud.

    Sign to the creative cloud, then go ahead and install Photoshop.

    Kind regards

    Tanuj

Maybe you are looking for

  • Screen resolution model 2355-A17 T430?

    Hi, I seeks a T430 renovated online, but want to 1600 x 900 screen - cannot find the sheet of that model, any where. It is not in all the PSREF docs on the Lenovo site. Anyone know if the A17-2355 has the screen resolution 1600 x 900? Thank you

  • Windows server 2012 crashes at startup

    After update my server windows 2012. I restarted and found myself stuck on a black background with the active mouse cursor. Please kindly help UPDATE: It turns out my hard drive has been corrupted, he was not able to start after the reboot.

  • Webcam Live mail error msg connection failed in the outgoing message

    Whenever I try to send e-mail with windows live mail, I get an error 25 and the connection failed. If I delete the outgoing msg, connects immediately. I see other people with the same problem.

  • How to disable the automatic backup in windows 7

    I changed to 'never' backup scheduler, but again, the computer saves the data and invites me to insert a disc for the copy of the backup files. I have my files backed up offline and don't want or need this help. How can I disable it either doesn't wo

  • 3 RVS 4000 with VPN connection

    Hello I want to connect in a triangle 3 RVS 4000 router with VPN I configured 3 routers, which can connect to the Internet. Each of them are configured as the gateway. I created 2 tunnels on each router. But the vpn connection cannot be established.