Check the values of the hierarchy

Hello
I have a requirement where I need check the data of the child if the parent is not satisfying the condition
Here is the sample table and data.

I have a test_test1 of the Table that contains the data parent and child
create table test_test1 (dependent_id number ,dependent_upon_id number)

insert into test_test1 values(2,1)
insert into test_test1 values(3,2)
insert into test_test1 values(4,3)

select dependent_id ||' depends on'|| ' '||dependent_upon_id  
  from test_test1
There is another table to check the status of the id in the table above.
create table test_test2 (id number,i_m varchar2(11))

insert into test_test2 values(1,'ISUE')
insert into test_test2 values(2,'MN')
insert into test_test2 values(3,'MN')
insert into test_test2 values(4,'MN')
Now if the lookup id is 3, check the State, be it ISUE / MN.
If the State is "MN" then check with that is the State of his child;  4 (the child can be greater than 1)
If id 4 has the "MN" State, to consult because he was a child extra until he got the State as 'ISUE. If there is not more far childs are 'MAY', and then mark search (3) as inactive, active id otherwise.

Note: The id is not in additional order that I gave in the data of test as 1,2,3... etc.

Could you help me how to achieve the above requirement


Thank you..

Published by: smile on December 30, 2011 11:57
select *
  from (
        select dependent_upon_id  as ID
              ,case when instr(sys_connect_by_path(t2.i_m,','),'ISUE')>0
                    then 'ACTIVE'
                    else 'N/A'
                end               as status
              ,max(level) over(partition by dependent_upon_id)  as maxl
              ,level                                            as l
          from test_test1 t1
          join test_test2 t2
            on (t2.id = t1.dependent_upon_id)
         connect by prior t1.dependent_upon_id = t1.dependent_id
        union all
        select e.id
              ,decode(e.i_m, 'ISUE', 'ACTIVE', 'N/A') status
              ,1
              ,1
          from test_test2 e
         where not exists(select 1
                            from test_test1 r
                           where r.dependent_upon_id = e.id )
       )
where ID = 2 -- 3
  and maxl = l 

Tags: Database

Similar Questions

  • DRM validation to check the existence of nodes in a different hierarchy as a property value

    Hello gurus,

    I have two hierarchies, named A and B respectively. I need to create a validation for nodes in A hierarchy that checks the value of a property such that the node must have the property value equal to any node name in the hierarchy B.

    Means that the values for this particular property for the nodes in A hierarchy must exist as a node in the hierarchy B.

    It would be very grateful if someone can give an idea to achieve this.

    Hello

    Try this in a type formula validation-

    NodeInHier (PropValue (Custom.PropName), B)

    This returns false if the value of the property is not a node in the hierarchy B and True if it's.

    So, you will get a validation message whenever the property is loaded with a value that is not a node in the hierarchy of B.

    Thanks, let me know

    Denzz

  • How to get the value of the property and the hierarchy specified in a global property, by javascripts

    Hi DRM team:

    I want to get a property value and precise when the hierarchy from. So, I thought that LocalNodeObjects method GetReferenceInHier (hierAbbrev), but the question is coming, I'm working on a global property, node. GetReferenceInHier (hierAbbrev) is not available. How can I get the value of the specified node hierarchy?

    Thanks for any response.

    Jim

    Hi Jim.cyciopes

    Try this-

    var worm is node. Version;

    var hier_ref = worm. HierByAbbrev ("name of your hierarchy");

    var node_ref is hier_ref. NodeByAbbrev (node. ABBREV);

    {if(node_ref!=null)}

    var propval is node_ref. VarValeurProp ("YourPropertyName");

    }

    Return propval;

    Thank you

    Denzz

  • Allowing entry of the value of a property at the level of the hierarchy and restricting to whole new level.

    Hi all

    I have two property definition Custom.Levelnumber and Custom.Allowattribute which are the goods as well as Local property node level.

    I want validation to restrict the user to allow any value for the Custom.Allowattribute property for any level of hierarchy other than level 6 i, e Custom.Levelnumber with the value 6.

    all other classes in the hierarchy must have an empty value for the Custom.Allowattribute property.

    Hi Madhu,

    Try this-

    If)

    Not (Equals (Integer, PropValue (Custom.LevelNumber), 6));

    Not (IsDefinedPropVal (Custom.Allowattribute, ABBREV (())).

    True)

  • How to check the value of Disqualification working correctly?

    Hello

    I have problems using the processor to check the value in Disqualification. I want to check the customer name field for how many names contain 'TEST' in them. Here are the steps I follow, I hope that someone can identify where I'm wrong:

    1. Add checking the value

    2. in the ATTRIBUTES tab, add "Customer Name" as the field of Validation

    3. in the OPTIONS tab, add 'TEST' as against value to compare files, choose "is equal to", as the comparison operator, select 'Yes' to Ignore Case.

    In reviewing the data, I see many instances where TEST is in the name of customer - but the value record tells me that there is no example of this.

    Have I missed something obvious/fast?

    Thank you!

    Checking the value does not have a check Contains. Use the list check with the Contains option for this.

    You can press F1 on each processor for its help page if you are not sure about what he does.

    Mike

  • How to check the page dirty with default values existing in viewObject?

    Hi all

    I use JDeveloper 11.1.1.4.

    I have two pages in my application. I am browsing for page2 page1.

    Before opening page 2 I created new line page 2 notice of object using method 'Create Insert()' with some default values by using the ViewRowImpl class.

    My problem is that I have a button to return to Page 2. If I click the back button, then check the Application module is dirty or not.

    But it always shows AM is dirty due to I'm setting some default values in ViewRowImpl. If I avoid the default values in ViewRowImpl then AM dirty check works fine.

    My Question is how to check the AM (or) dirty Page with default values in the object view?

    My bean Codes:

    Links DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();

    DataControl dc = bindings.findDataControl("AppModuleDataControl");

    ApplicationModuleImpl am = ((ApplicationModuleImpl) dc.getDataProvider ());

    If (am.getDBTransaction (.isDirty (()))

    {

    return "Page is dirty."

    }

    My Jspx Codes:

    < af:commandLink id = "cl6" text = '2 '.
    shortDesc = "Add Row in Page2"
    actionListener = "#{bindings." Action CreateInsert.execute}' = 'Edit' >

    Thank you

    David...

    see this

    http://www.techartifact.com/blogs/2013/11/how-to-check-ifdirty-is-modified-for-view-object.html

    http://www.jobinesh.com/2011/05/checking-for-dirty-data.html

  • Checking the negative value

    Hey guys I have a result on the ground which is of type varchar, but it stores numbers. I want to check if the value is negative or not. The code below works perfectly except for 1 case where the result has only ' - '. -indicates a missing value not a negative... How this can be fixed. Here is my code snippet.
    -Search for numeric values
    IF (trim (TRANSLATE (resvalue,'+ -. 0123456789', ' ')) IS NULL) THEN
    -Look for the negative value if the value is numeric
    IF (substr (resvalue, 1, 1) = '-' AND substr (resvalue, 0, 1) is not null) THEN
    v_ret_msg: = v_result_name | "" A negative result. "

    Also check the LENGTH of resvalue.
    That is to say:
    If length (resvalue) = 1 and substr (resvalue, 1, 1) = '-' then...

  • How to check the current values of COMMIT_WAIT and COMMMIT_LOGGING

    Is it possible that you can check in a session to determine the current settings for COMMIT_WAIT and COMMMIT_LOGGING? I am not referring to a situation where they are defined via ALTER SYSTEM and changed the world, but changed using ALTER SESSION and locally defined. I'm currently testing a trigger to do it for a very specific batch user and just need to be able to log on and check if the adjustment was established successfully or not.

    >
    Is it possible that you can check in a session to determine the current settings for COMMIT_WAIT and COMMMIT_LOGGING?
    >
    Well, since these are the initialization parameters, you can check the PARAMETER V view $

    select name, value from v$parameter
    where name like 'commit%'
    
    NAME,VALUE
    commit_point_strength,1
    commit_write,
    commit_wait,
    commit_logging,
    

    And after changing their

    alter session set commit_logging = 'IMMEDIATE';
    alter session set commit_wait = 'FORCE_WAIT' ;
    
    NAME,VALUE
    commit_point_strength,1
    commit_write,
    commit_wait,FORCE_WAIT
    commit_logging,IMMEDIATE
    
  • How to check the existence of a value in a table before copying the data?

    Experts,

    I have a requirement in which I need to copy data (4 columns) table A to table B (4 columns)

    Table A (entry)

    PART_ID PART_NAME PART_OPT_CD ENGG_OPT_CD

    1 "AAA" 10 100
    2 'BBB' 20 200
    3 'CCC' 30 300
    4 'DDD' 40 400
    5 'EEE' 50 500


    I have a table named OPTIONS with a single column. This is a table of reference of business which has the master list of option codes.

    OPT_CD
    10
    20
    30
    50
    60
    100
    200
    400
    500


    I need to copy Table A to Table B, but in doing so, I need to check the values of columns 3 and 4 in the OPTIONS array.
    If there is copy the folder B. Otherwise error in the log in a file/table and continue with the next copy

    TABLE B (exit)

    PART_ID PART_NAME PART_OPT_CD ENGG_OPT_CD

    1 "AAA" 10 100
    2 'BBB' 20 200
    5 'EEE' 50 500

    WARNING file or a table should have the details below.

    300 ENGG_OPT_CD does not exist in the table OPTIONS, so part_id 3 have not migrated
    40 PART_OPT_CD does not exist in the table OPTIONS, then part_id 4 have not migrated

    Company don't bother about the format of error, we need this information to correct the OPT_CD in the OPTIONS table.

    Can anyone suggest a better way to do this. Thank you for your help in advance

    Hello

    Its very similar to your previous post.
    Re: PL/SQL help
    The only difference being that you have to outer join to your superimposed master table, since your search in two columns values occur only in a single column on your Master table.

    Something like that;

    create table a (part_id number, part_name varchar2(10),part_opt_cd number,engg_opt_cd number);
    
    insert into a
    (select 1 Part_ID, 'AAA' Part_Name, 10 Part_Opt_CD, 100 ENGG_Opt_CD from dual union all
    select 2, 'BBB', 20, 200 from dual union all
    select 3, 'CCC', 30, 300 from dual union all
    select 4, 'DDD', 40, 400 from dual union all
    select 5, 'EEE', 50, 500 from dual union all
    select 6, 'FFF', 60, 500 from dual
    )
    /
    
    create table b (part_id number, part_name varchar2(10),part_opt_cd number,engg_opt_cd number);
    
    insert into b
    (select 1 Part_ID, 'AAA' Part_Name, 10 Part_Opt_CD, 100 ENGG_Opt_CD from dual union all
    select 2, 'BBB', 20, 200 from dual union all
    select 5, 'EEE', 50, 500 from dual
    )
    /
    
    Create table master (OPT_CD number);
    
    insert into master (
    select 10 opt_cd from dual union all
    select 20 from dual union all
    select 30 from dual union all
    select 50 from dual union all
    select 60 from dual union all
    select 100 from dual union all
    select 200 from dual union all
    select 400 from dual union all
    select 500 from dual
    )
    /
    
    create table log_msg
    (msg varchar2(100)
    ,t timestamp default current_timestamp)
    / 
    
    SQL> insert all
      2    when Master1_ID is not null and
      3         Master2_ID is not null then
      4      into b (Part_ID, Part_Name, Part_Opt_CD, ENGG_Opt_CD)
      5      values (Part_ID, Part_Name, Part_Opt_CD, ENGG_Opt_CD)
      6    when Master1_ID is null or
      7         Master2_ID is null then
      8      into log_msg (msg) values (Part_Opt_CD || ' ' || ENGG_Opt_CD || ' does not exist on the Master table')
      9  select m1.Opt_CD      as Master1_ID
     10        ,m2.Opt_CD      as master2_ID
     11        ,a.Part_ID      as Part_ID
     12        ,a.Part_Name    as Part_Name
     13        ,a.Part_Opt_CD  as Part_Opt_CD
     14        ,a.ENGG_Opt_CD  as ENGG_Opt_CD
     15  from (
     16        select a.Part_ID, a.Part_Name, a.Part_Opt_CD, a.ENGG_Opt_CD
     17        from a
     18        left outer join b on  a.Part_ID = b.Part_ID
     19        where b.Part_ID is null
     20      ) a
     21  left outer join master m1 on   a.Part_Opt_CD = m1.Opt_CD
     22  left outer join master m2 on   a.ENGG_Opt_CD = m2.Opt_CD
     23  /
    
    3 rows created.
    
    SQL> select * from log_msg;
    
    MSG                                         T
    ------------------------------------------- -------------------------
    40 400 does not exist on the Master table   05-OCT-11 09.44.17.621000
    30 300 does not exist on the Master table   05-OCT-11 09.44.17.621000
    
    SQL> select * from b;
    
       PART_ID PART_NAME  PART_OPT_CD ENGG_OPT_CD
    ---------- ---------- ----------- -----------
             1 AAA                 10         100
             2 BBB                 20         200
             5 EEE                 50         500
             6 FFF                 60         500
    

    Note, I have included an additional line in table A in order to prove that the INSERTION will occur in table B. Errors, as you can see have been inserted in the table LOG_MSG.

    Published by: bluefrog October 5, 2011 09:48

  • Can LOV check the value in the table and view so absent?

    Hello.

    If you have 2 simple tables. One called "Table1", and another table used to fill a LOV called "Table2" can LOV display a list of the missing items in table 1? If so how would that be? Let's say that the LOV table consisted of two fields, a field called 'ID' and a field called 'Document '. The 'Document' field would be the display value and the 'ID' field would be the return value. The first table 'Table 1' would be the value returned by the username returned by V ('APP_USER') and 'ID'.

    What would be the SQL to watch 'Table1' and display only the records for V("APP_USER') in the LOV that do not yet exist in 'Table1 '?

    Sorry if it sounds simple, but I can't get out.


    Kind regards

    Steve W

    Hi Steve,.

    Steve Welch wrote:
    Sorry if I wasn't clear. Lets say I have 5 documents numbered 1 to 5. The 1,2,3,4,5 and the user that created would be on a line for each. The picture would not infinite because there should be only 5 folders for that user. I can create a query that checks the same number for a user exists in both tables but not it doesn't.

    Looks like that to me, we need to rethink the design of your database. Correct me if I'm wrong...

    Table 1 lists the documents that a user has created, and then you want a LOV to see a list of the documents that the user is still to create. To do this, you need some sort of logic that determines a precise list of the documents that a user must create. This could be done by a table of the required documents and then the list could be created simply by using a set operation, i.e. with a negative statement

    Select annual, required_docs doc_desc
    less
    Select annual, doc_desc from created_docs where created_by =: APP_USER.

    In a well-designed application, it would be a little more sophisticated than that, but I hope you get the idea. As I said earlier, you may need to take a step back and learn a little more about relational database design.

    Concerning
    André

  • Preaggregation through value according to size of the hierarchy in 11g

    Hi all



    I created a cube with 6 dimensions in olap 11g. One of these six dimensions has only a single hierarchy which is based hierarchy. I chose the level based aggregation I know what exactly users go to the query. When I was going through the dimensions to choose the levels of preaggregating I noticed there was that no option available for my value based hierarchy dimension (I could see the option 'all' for the same case in 10 g) then I tried to look for the definitions of the underlying objects in order to ensure that it will be preaggregating in my dimension hierarchy of value according.

    I found the value that my value according to size of the hierarchy in object < NAME of the CUBE >SOLVEAGGMAP AWM uses to decide what values of dimension of preaggregating but if I rpr on this set of value (rp r < NAME of the CUBE >SOLVE< NAME of DIMENSION > _PVSET), it shows NA, so my question is what can I pre aggregation through dimension hierarchy according to value in olap 11 g?

    OLAP Version: 11.2.0.1
    AWM version: 11.2.0.1

    Thank you

    Even if you know exactly what levels your users ask, pre-calculate the base per cent (30%) may still be faster in practice, because queries are returned, use the "sparse loopback" instead of "dense closure." It was the biggest advantage of unique performance of 11g over 10g.

    But if you want to continue using the base level precompute, then you should look at the XML model for the cube (as recorded by AWM, for example). Inside, you should find what we call PrecomputeCondition. This defines the set of members that are precalculated. Here is an example that I just created using the GLOBAL schema

    
     
    
    

    The PrecomputeCondition is also visible in the USER_CUBES view.

    SELECT PRECOMPUTE_CONDITION
    FROM USER_CUBES
    WHERE CUBE_NAME = 'MY_CUBE';
    

    You can change this condition in the XML to specify an alternative 'level unfounded' precompute condition for any dimension. For example, if you set an attribute named "SHOULD_PRECOMPUTE" on your PRODUCT dimension which is 1 for members to be precalculated and 0 for all others, you can change the condition as follows.

    
     
    
    

    If you recreate the cube from the XML with this condition, then the PVSET valueset that you discovered should contain all the dimension members for which the value of the attribute is 1.   This gives you complete control over what is precalculated.   Note that AWM does not support this form of State, so it will not be displayed if you go to the Precompute tab, but it is valid for the server.  The PL/SQL below will change the PrecomputeCondition (for the cube named MYCUBE) without going through MN.

    begin
      dbms_cube.import_xml(q'!
    
      
        
          
            
              
            
          
        
      
    
    !');
    end;
    /
    
  • JavaScript to check the value of the Textbox

    Hi all

    I have a few simple javascript in the header of my page to check the value of an element... There is no errors in Firebug, but the alert window is also never coming.
    if ($v('P2_ITEM') == 'VALUE1')
    {
    alert('VALUE1');
    }
    if ($v('P2_ITEM') == 'VALUE2')
    {
    alert('VALUE2');
    }
    if ($v('P2_ITEM') == 'VALUE2')
    {
    alert('VALUE2');
    }
    Thanks for any help.

    Use double quotes in JS to check the string values:

    function test_choice()
    {
    if ($x('P2_ITEM') == "Test1")
    {
    alert("Test1");
    }
    if ($x('P2_ITEM') == "Test2")
    {
    alert("Test2");
    }
    if ($x('P2_ITEM') == "Test3")
    {
    alert("Test3");
    }
    }
    
  • Customize alert messages to check the duplicate value and alert success

    Hi all

    I want to show two alert against the button 'Submit' even at -.

    1 the attention of messages to check the duplicate value and show the duplicate value found alert and
    2 alert if successful the form's success to commit no duplicate values found.

    I did all the thing but what alert-1 show and I pressed the ok button of the alert, then the second alert also shows that I don't want to show.

    Who can I do about it? Have someone to help me!

    Arif

    Use the folliwng in PRE-INSERT-TRIGGER.

    There is not a lot of changes with the exception

    where CANCELLATION_USERID =: CANCELLATION_USERID;

    and

    If valExists > 0 then

    declare
    
     valExists number;
    
    begin
    
     select count(*) into valExists
     from USERDELETION
     where CANCELLATION_USERID = to_char(:CANCELLATION_USERID);
    
     if valExists > 0 then
      message('Duplicate value found !');
      -- show_alert('ERROR_ALERT');
     else
      message('All is well');
      -- show_alert('All is well ');
     end if;
    
    end;
    
  • Separate the values that are not in the hierarchy...

    Hi all

    Please help me build the following query:

    Parent child
    ==== ===
    10 20
    20 30
    30 40
    50 60
    70 80

    etc... In the above data we ensure there's a great single parent say 10 and values 50,60,70,80 etc are not attached to the grandparent 10. so I need to display values that are forgotten to fix on the Top 10 of node that is to say, here 50,60,70,80 etc. If my query is useful in retreving these values then I can attach them to the hierarchy.

    Thanks in advance.

    Kind regards
    Kalyan
    SQL>WITH t AS
      2       (SELECT 10 AS par, 20 AS chi FROM DUAL UNION ALL
      3        SELECT 20, 30 FROM DUAL UNION ALL
      4        SELECT 30, 40 FROM DUAL UNION ALL
      5        SELECT 50, 60 FROM DUAL UNION ALL
      6        SELECT 70, 80 FROM DUAL)
      7  SELECT *
      8    FROM t
      9   WHERE chi NOT IN(SELECT     chi
     10                          FROM t
     11                    CONNECT BY PRIOR chi = par
     12                    START WITH par = 10);
    
           PAR        CHI
    ---------- ----------
            50         60
            70         80
    

    HTH, Urs

  • How to check the value of the space of the tablespaces and tables when errors occur?

    Hi Experts,

    For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?

    Thanks for your help

    Hello

    Select df.tablespace_name "Tablespace"

    totalusedspace 'Used MB',

    (df.totalspace - tu.totalusedspace) "MB free.

    DF. TotalSpace 'Total MB. "

    round (100 * ((df.totalspace-tu.totalusedspace) / df.totalspace))

    "PCT free."

    Of

    (select nom_tablespace,

    Round (Sum (bytes) / 1048576) TotalSpace

    from dba_data_files

    Group by tablespace_name) df,.

    (select round (sum (bytes) /(1024*1024)) totalusedspace, nom_tablespace)

    from dba_segments

    you group by tablespace_name)

    where df.tablespace_name = tu.tablespace_name

    and df.tablespace_name = "";

    For example, lets say we get ORA-01653: unable to extend table of error. How to check the size of the table and a tablespace? And how understanding is full?

    Is to say clearly to the question (you can let us know what you have understood so we can fix)

    [oracle@machine1 ~] $01653 oerr ora

    01653, 00000, "impossible to extend %s.%s table by %s in %s tablespace»

    * Cause: Failed to allocate a certain measure the required number of blocks for

    a segment of the table in the specified tablespace.

    * Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more

    storage of files indicate.

    -Thank you

    Pavan Kumar N

Maybe you are looking for