Hierarchical data with SQLAssembler: pointers vs ids

Hi!
Ive got parent-children nodes that I need to store and retrieve from an SQL database, using SQLAssembler. The parents and children are a recursive tree, all of the same class.
The data is displayed in AdvancedDataGrid, which requires the children attribute. In the SQL table, I prefer one parent relation instead. Therefore my model uses both, which increases the complexity.
My problem, I think, is that the Flex/ActionScript model is using pointers (parent), while the SQL tables uses the parentId (integer).
How do I deal with the two different ways of referring to the parent/child? Do I need to implement both in my managed objects?
My current implementation includes both SQL ids and AS pointers. On the result event, I create pointer relationships based on the SQL node ids. I think this may be unnecessary, as LCDS is passing the whole tree as one, to the database after my update.
I basically unsure how to implement these parent/child relationships in ActionScript and/or SQL tables / statements. Because my current implemnations have been mucking up halfway through.
Any hints are greatly appreciated.
Cheers,
Vegard

Well, just start by making a Node class. To allow Nodes to have children, make each Node have an array (or arraylist, vector, etc.) of other Nodes.
for example:
class Node{
  private ArrayList<Node> children;
}Put whatever else you need in there.
You can then traverse these through methods you write, to return child nodes. If you need the Nodes to have knowledge of their parents, add a Node parent; variable in your Node class.
Essentially, keep things as simple as possible, and this will allow you to write cleaner code and also decide on the depth of the structure at runtime, like you describe.

Similar Messages

  • How to modify hierarchical data with JavaAPI?

    Hi
    we have a hierarchical structure for "Categories" of products. Its a simple Table of type "Hierarchy".
    Now I need to add new entries to the Tree, or move existing entries to some different parents. But I can neither find a command like ModifyHierarchyTree nor is there a method to set the parent record on a HierNode instance.
    How can I set the parent node of a hierarchy node with JavaAPI 2?
    (Patch level is 5.5.42.65)
    Thanks in advance!

    Hi Roger,
    I think you can modify the Data Groups hierarchy directly from within the Add Objects dialog, by clicking the Edit button to open the Edit Data Groups dialog and then using the context menu as in any editable tree to add siblings and children, and to delete and rename existing nodes
    You can also edit the Data Groups hierarchy by choosing Objects ® Edit Data Groups from the main menu.
    Whereas other trees allow non-unique node names as long as sibling nodes do not have the same name, data group names must be unique across the entire Data Groupshierarchy.
    Hope it helped.
    Regards,
    Krutarth

  • Avoiding change pointers for data with status planned

    Hi,
    we have to distribute HCM-data, standard infotypes and customer infotypes, into other SAP sytems. One of the receiving systems must not get data with the status planned (istat = 2).
    Which would be the best way to avoid planned data in the receiving system? Is it possible to avoid creating change pointers for planned data in the delivering system or have I to delete the planned data in the receiving system while processing the idocs via user-exit?
    Best regards
    Stefan

    Dear Stefan,
    You can create the change pointers manually from the IDOC data (e.g.with  FM CHANGE_POINTERS_CREATE) during the inbound processing within of the customer-exits of enhancement RHALE001 or within an own BAdI implementation of BAdI HRALE00INBOUND_IDOC.
    Or else you can use method IDOC_DATA_FOR_RECEIVER_MODIFY of BAdI HRALE00OUTBOUND_IDOC. In this case please make sure that note 1292241 is implemented.
    Hope it helps,
    Christine

  • AdvancedDataGrid - create Array (cfquery) with children for hierarchical data set

    I'm trying to create an AdvancedDataGrid with a hierarchical
    data set as shown below. The problem that I am having is how to
    call the data from a ColdFusion remote call and not an
    ArrayCollection inside of the Flex app (as below). I'm guessing
    that the problem is with the CFC that I've created which builds an
    array with children. I assume that the structure of the children is
    the issue. Any thoughts?
    Flex App without Remoting:
    http://livedocs.adobe.com/labs/flex3/html/help.html?content=advdatagrid_10.html
    <?xml version="1.0"?>
    <!-- dpcontrols/adg/GroupADGChartRenderer.mxml -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable]
    private var dpHierarchy:ArrayCollection= new
    ArrayCollection([
    {name:"Barbara Jennings", region: "Arizona", total:70,
    children:[
    {detail:[{amount:5}]}]},
    {name:"Dana Binn", region: "Arizona", total:130, children:[
    {detail:[{amount:15}]}]},
    {name:"Joe Smith", region: "California", total:229,
    children:[
    {detail:[{amount:26}]}]},
    {name:"Alice Treu", region: "California", total:230,
    children:[
    {detail:[{amount:159}]}
    ]]>
    </mx:Script>
    <mx:AdvancedDataGrid id="myADG"
    width="100%" height="100%"
    variableRowHeight="true">
    <mx:dataProvider>
    <mx:HierarchicalData source="{dpHierarchy}"/>
    </mx:dataProvider>
    <mx:columns>
    <mx:AdvancedDataGridColumn dataField="name"
    headerText="Name"/>
    <mx:AdvancedDataGridColumn dataField="total"
    headerText="Total"/>
    </mx:columns>
    <mx:rendererProviders>
    <mx:AdvancedDataGridRendererProvider
    dataField="detail"
    renderer="myComponents.ChartRenderer"
    columnIndex="0"
    columnSpan="0"/>
    </mx:rendererProviders>
    </mx:AdvancedDataGrid>
    </mx:Application>
    CFC - where I am trying to create an Array to send back to
    the Flex App
    <cfset aPackages = ArrayNew(1)>
    <cfset aDetails = ArrayNew(1)>
    <cfloop query="getPackages">
    <cfset i = getPackages.CurrentRow>
    <cfset aPackages
    = StructNew()>
    <cfset aPackages['name'] = name >
    <cfset aPackages
    ['region'] = region >
    <cfset aPackages['total'] = total >
    <cfset aDetails
    = StructNew()>
    <cfset aDetails['amount'] = amount >
    <cfset aPackages
    ['children'] = aDetails >
    </cfloop>
    <cfreturn aPackages>

    I had similar problems attempting to create an Array of
    Arrays in a CFC, so I created two differents scripts - one in CF
    and one in Flex - to build Hierarchical Data from a query result.
    The script in CF builds an Hierarchical XML document which is then
    easily accepted as HIerarchical Data in Flex. The script in Flex
    loops over the query Object that is returned as an Array
    Collection. It took me so long to create the XML script, and I now
    regret it, since it is not easy to maintain and keep dynamic.
    However, it only took me a short while to build this ActionScript
    logic, which I quite like now (though it is not [
    yet ] dynamic, and currently only handles two levels of
    Hierarchy):
    (this is the main part of my WebService result handler)....
    // Create a new Array Collection to store the Hierarchical
    Data from the WebService Result
    var categories:ArrayCollection = new ArrayCollection();
    // Create an Object variable to store the parent-level
    objects
    var category:Object;
    // Create an Object variable to store the child-level
    objects
    var subCategory:Object;
    // Loop through each Object in the WebService Result
    for each (var object:Object in results)
    // Create a new Array Collection as a copy of the Array
    Collection of Hierarchical Data
    var thisCategory:ArrayCollection = new
    ArrayCollection(categories.toArray());
    // Create a new instance of the Filter Function Class
    var filterFunction:FilterFunction = new FilterFunction();
    // Create Filter on the Array Collection to return only
    those records with the specified Category Name
    thisCategory.filterFunction =
    filterFunction.NameValueFilter("NAMETXT", object["CATNAMETXT"]);
    // Refresh the Array Collection to apply the Filter
    thisCategory.refresh();
    // If the Array Collection has records, the Category Name
    exists, so use the one Object in the Collection to add Children to
    if (thisCategory.length)
    category = thisCategory.getItemAt(0);
    // If the Array Collection has no records, the Category Name
    does not exist, so create a new Object
    else
    // Create a new parent-level Object
    category = new Object();
    // Create and set the Name property of the parent-level
    Object
    category["NAMETXT"] = object["CATNAMETXT"];
    // Create a Children property as a new Array
    category["children"] = new Array();
    // Add the parent-level Object to the Array Collection
    categories.addItem(category);
    // Create a new child-level Object as a copy of the Object
    in the WebService Result
    subCategory = object;
    // Create and set the Name property of the child-level
    Object
    subCategory["NAMETXT"] = object["SUBCATNAMETXT"];
    // Add the child-level Object to the Array of Children on
    the parent-level Object
    category["children"].push(subCategory);
    // Convert the Array Collection to a Hierarchical Data
    Object and use it as the Data Provider for the Advanced Data Grid
    advancedDataGrid.dataProvider = new
    HierarchicalData(categories);

  • Wanna learn to implement hierarchical data structure

    I want to learn the method of handling hierarchical data in Java
    For instance if there is some kind of data which contains 6 main nodes then every node contains 2 sub nodes and there are 4 nodes under the 3rd node where as the 5th one contains two more subnodes one under another.
    So how will that be implemented?
    Ofcourse it must be possible to implement it but how can I do the same if I do not know the depth and number of nodes and will get it during the runtime?
    I had attempted to do create some thing of this kind using Turbo C++ 3.5 but after two weeks of intensive programming I was left utterly confused with innumerable pointers and pointer to pointers and pointer to a pointer to a pointers and more. At last it was me who forgot which pointer was pointing to what.

    Well, just start by making a Node class. To allow Nodes to have children, make each Node have an array (or arraylist, vector, etc.) of other Nodes.
    for example:
    class Node{
      private ArrayList<Node> children;
    }Put whatever else you need in there.
    You can then traverse these through methods you write, to return child nodes. If you need the Nodes to have knowledge of their parents, add a Node parent; variable in your Node class.
    Essentially, keep things as simple as possible, and this will allow you to write cleaner code and also decide on the depth of the structure at runtime, like you describe.

  • What is hierarchical data transfer in functional location

    hai,
    i want to know indetail about hierarchical data transfer and horizontal data transfer in functional location.
    can any one help me in this regard....
    plz give information with some example if you dont mind...
    thanks in advance
    regards
    gunnu.

    Hi
    From SAP HELP
    Hierarchical Data Transfer
    Definition
    You can maintain data at a high level within a hierarchical object structure. The system will automatically transfer the data changes to the levels below that are affected.
    The maintenance planner group is changed for the clarification plant described in Functional Location. The employee responsible for maintaining the master data makes the change to the master record of the highest functional location C1 and saves the changes. The system automatically makes the same change for all affected functional locations below the functional location C1, and issues a message to inform the employee of these changes.
    Horizontal Data Transfer
    Definition
    With horizontal data transfer you can differentiate between:
    Data transfer from reference location to functional location
    Data transfer from functional location to installed piece of equipment
    The ABC indicator of the functional location C1-B02-1 "Ventilator" is to be changed for several clarification plants.
    The employee responsible for maintaining the master data makes the change in the master record of the reference functional location and saves the entries.
    The system automatically makes the same change for all affected functional locations that were assigned to this reference location and for the pieces of equipment that are installed at these locations. The system then issues a message informing the employee of the changes.
    Regards
    thyagarajan

  • How to retain form data with cfpdf flatten option

    I created an intertactive form from an existing pdf using
    Acrobat 8.0/Live Cycle designer. Now I am trying to use it in my
    application where I use cfpdfform tag to first populate the pdf,
    and then create a flattened copy of the form using cfpdf
    action="wrtite" flatten="yes" command. But when I flatten the form,
    the form data is lost. This does not happen with other government
    forms like Form I-9 or W-4 that could be downloaded as interactive
    forms from their respective sites.
    I came across this article through a Google search
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_02.html.
    If you scroll down about half the page you will see this:
    "You can use the cfpdf tag to assemble interactive PDF form
    files into a single PDF document and flatten forms created in
    Acrobat (by using the flatten attribute with the write action);
    however, to process PDF form data, use the cfpdfform and related
    tags. You cannot use the cfpdf tag to flatten forms created in
    Adobe LiveCycle Designer ES."
    This is confusing - why can't the forms created in LiveCycle
    be flattened? What other tools we have to create interactive forms
    that can be flattened with form data?
    Please assist me with your pointers and responses. Would
    appreciate an early reply.
    Thanks very much.
    Raj

    Here's how I did it.  LiveCycle form does work in ColdFusion.  It even includes an image wich works untill I flatten the form.

  • IS-Utilities trying to tie FICA data with GL

    We have an IS-Utilities installation where we are trying to tie the monthly revenue totals from the FICA module with the data that is posted to the General Ledger.  We can come pretty close, however we are unable to hit the value exactly.  We realize there will be some variation due to timing of the data loads, however I was wondering if anyone else had tried this before, and if so, could you please provide me with some pointers.
    The FICA data we're using comes from the DFKKOP table in R/3, through a custom extractor.  We are a Public Sector installation, so we are actually using the Special Ledger rather than the General Ledger, but that shouldn't be an issue.  Any help would be appreciated.
    Thank you very much
    Michael Frank

    Hallo Herr Frank,
    können wir uns in Deutsch unterhalten?
    Ich verstehe Ihr Problem leider nicht ganz.
    Freundlich Grüße
    Ralf
    Message was edited by:
            ralf wagensommer

  • Need help to pivot the data with hierarchy

    Dear Team,
    I have hierarchical data in the table as shown below
    SQL> Create Table t As
      2  (
      3  Select 97250528 col1, 'TSD' col2,  97250528 col3,   'WAV' col4 From dual Union All
      4   Select 75020160     , 'ASD'     ,  97250528     ,   'TSD'      From dual Union All
      5   Select 69150832     , 'PA'      ,  75020160     ,   'ASD'      From dual Union All
      6   Select 49150538     , 'DB'      ,  69150832     ,   'PA'       From dual Union All
      7   Select 49150538     , 'WAV'     ,  49150538     ,   'DB'       From dual Union All
      8   ------------
      9   Select 97251520 col1, 'TSD' col2,  97251520 col3,   'WAV' col4 From dual Union All
    10   Select 75020689     , 'ASD'     ,  97251520     ,   'TSD'      From dual Union All
    11   Select 69151039     , 'PA'      ,  75020689     ,   'ASD'      From dual Union All
    12   Select 49150672     , 'DB'      ,  69151039     ,   'PA'       From dual Union All
    13   Select 49150672     , 'WAV'     ,  49150672     ,   'DB'       From dual
    14  );
    Table created
    SQL> select *
      2  from t;
          COL1 COL2       COL3 COL4
      97250528 TSD    97250528 WAV
      75020160 ASD    97250528 TSD
      69150832 PA     75020160 ASD
      49150538 DB     69150832 PA
      49150538 WAV    49150538 DB
      97251520 TSD    97251520 WAV
      75020689 ASD    97251520 TSD
      69151039 PA     75020689 ASD
      49150672 DB     69151039 PA
      49150672 WAV    49150672 DB
    10 rows selected
    I am using connect by prior clause to get the data in correct order.
    below is the SQL i am using..
    SQL> Select Level lvl,
      2          col3,
      3          col4
      4   From t
      5   Start With col3 In ('97250528','97251520')
      6   And        col4 In ('WAV')
      7   connect by Nocycle Prior col1 = col3
      8              And     Prior col2 = col4;
           LVL       COL3 COL4
             1   97250528 WAV
             2   97250528 TSD
             3   75020160 ASD
             4   69150832 PA
             5   49150538 DB
             1   97251520 WAV
             2   97251520 TSD
             3   75020689 ASD
             4   69151039 PA
             5   49150672 DB
    10 rows selected
    The data i am getting is correct one. However i want output in the following format..
         WAV             TSD              ASD             PA             DB
    1     97250528     97250528     75020160     69150832     49150538
    2     97251520     97251520     75020689     69151039     49150672
    When i use max + case statement i am getting in-correct results as there is no group by key
    Kindly give me some hints or tips to pivot the data or should i go to PL/SQL to pivot the data.
    Regards
    nic

    Hi Dbb,
    Connect_by_root did the trick i guess
    Select max(Case When col4 = 'WAV' Then col3 End) wav,
           max(Case When col4 = 'TSD' Then col3 End) tsd,
           max(Case When col4 = 'ASD' Then col3 End) ASD
    From
    Select  CONNECT_BY_ROOT col1 col,
            col3,
            col4
    From t
    Start With col3 In ('97250528','97251520')
    And        col4 In ('WAV')
    connect by Nocycle Prior col1 = col3
                And     Prior col2 = col4
    Group By col;    
           WAV        TSD        ASD
      97250528   97250528   75020160
      97251520   97251520   75020689
    Let me execute this over bulk-sets of data...
    thanks for this pointer and hint..

  • How to model hierarchical data?

    I need a way to model hierarchical data. I have tried using an object so far, and it hasn't worked. Here is the code for the class I made: http://home.iprimus.com.au/deeps/StatsGroupClass.java. As you can see, there are 4 fields: 1 to store the name of the "group", 2 integer data fields, and 1 Vector field to store all descendants. Unfortunately, this this not seem to be working as the Vector get(int index) method returns an Object. This is the error I get:
    Test.java:23: cannot resolve symbol
    symbol  : method getGroupName  ()
    location: class java.lang.Object
          echo("Primary Structure with index 0: " + data.get(0).getGroupName());
                                                            ^
    1 error I figure I can't use the approach I have been using because of this.
    Can anyone help me out?

    Test.java:23: cannot resolve symbolsymbol  : method getGroupName  ()location: class java.lang.Object      echo("Primary Structure with index 0: " + data.get(0).getGroupName());                                                        ^1 errorYou need to cast the return value from get(0):
    ((YourFunkyClass)data.get(0)).getGroupName();Be aware that you're opening yourself up to the possibility of a runtime ClassCastException. You could consider using generics if you can guarantee that the data Vector will contain only instances of YouFunkyClass.
    Hope this helps

  • Tree interface concept for hierarchical data creation/modification

    I am designing an interface for hierarchical data creation and maintenance. The interface will have to provide all basic data modifications options:
    edit an existing node, add new child/parent/sibling, as well as removing, sorting, dragging and dropping nodes around. Flex tree control is fully capable of all these functions while coding is not going to be a simple task. Has anyone worked on something like this? Any conceptual ideas?
    Thanks

    WOW Odie! You're awesome !! It worked like a charm, I created a view as you suggested:
    CREATE OR REPLACE FORCE VIEW "VIEW_TASKS_PROJECTS_TREE" ("ID", "PARENT_ID", "NODE_NAME") AS
    SELECT to_char(id) as id
    , null as parent_id
    , project_name as node_name
    FROM eba_task_projects
    UNION ALL
    SELECT to_char(id)
    , to_char(project_id)
    , task_name
    FROM eba_task_tasks;
    And then I created a new tree with the defaults and customized the Tree query a bit (just added the links really):
    select case when connect_by_isleaf = 1 then 0
    when level = 1 then 1
    else -1
    end as status,
    level,
    "NODE_NAME" as title,
    null as icon,
    "ID" as value,
    null as tooltip,
    'f?p=&APP_ID.:22:&SESSION.::NO::P22_ID,P22_PREV_PAGE:' || "ID" || ',3' as link
    from "#OWNER#"."VIEW_TASKS_PROJECTS_TREE"
    start with "PARENT_ID" is null
    connect by prior "ID" = "PARENT_ID"
    order siblings by "NODE_NAME"
    Thanks man, you saved me a lot of time and headaches :)

  • Hierarchical Data in Xcelsius (4 Levels)

    Hello ..
    is it possible to show hierarchical data for 4 Levels in Xcelsius.
    Example:
    first top-Down menu contains Countries. After selection of country the Diagramm should show Measures of the selected country
    second Top Down for Regions should show me dynamically only the Regions of the pre selected country
    Same thing with third Top Down for City and city Code ..
    Is it possible ..?

    Hello,
    filters are very restricted. The end result of filters has to be exactly 1 row to apply them.
    Category selectors offers more freedom but not enough to navigate trough 4 Hierarchies.
    It s normally not the purpose of excelsius to navigate trough information. But Customers usually don t make the difference between Reporting and Dashborads.

  • How to delete hierarchical data?

    Hello,
    I have a table with hierarchical data. I want to delete data based on a condition, but maybe this condition is only present in the topmost hierarchy.
    In my example I have rows identified by id and a changed_by containing the id of the row that replaced (invalidated) this row. From these I want to delete data where descr in the leaf nodes is 'A'.
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    DROP TABLE test_del;
    CREATE TABLE test_del (
         CONSTRAINT pk_del PRIMARY KEY (id)
        ,id         NUMBER
        ,changed_by NUMBER
         CONSTRAINT fk_del
         REFERENCES test_del (id)
        ,descr      VARCHAR2(10)
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (3,NULL,'A');
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (2,3,'A');
    INSERT INTO test_del (ID,changed_by,descr)
    VALUES (1,2,NULL);
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (6,NULL,'A');
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (5,6,'A');
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (10,NULL,'B');
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (9,10,'B');
    INSERT INTO test_del (id,changed_by,descr)
    VALUES (8,9,'B');
    COMMIT;
    SELECT  *
    FROM    test_del
    CONNECT BY PRIOR id = changed_by
    START WITH descr = 'A' AND changed_by IS NULL;
            ID CHANGED_BY DESCR
             3            A
             2          3 A
             1          2
             6            A
             5          6 A
    DELETE FROM test_del WHERE descr = 'A';
    ORA-02292: integrity constraint (FE.FK_DEL) violated - child record found
    Of course I get ORA-02292 in this case, but how can I write a correct statement that deletes the data shown by the select?
    Regards
    Marcus

    You need to follow the hierarchy:
    DELETE FROM test_del
          WHERE ROWID IN (
              SELECT ROWID
                FROM test_del
             CONNECT BY PRIOR id = changed_by
               START WITH descr = 'A'
                      AND changed_by IS NULL);

  • Hierarchical data structure

    I am trying to represent the following data structure in hierarchical format ---- but I am not going to use any swing components, so jtree and such are out, and xml is probably out. I was hoping some form of collection would work but I can't seem to get it!
    Example Scenario
    Football League --- Football Team -- Player Name
    West
    ------------------------------Chiefs
    -------------------------------------------------------------xyz
    -------------------------------------------------------------abc
    -------------------------------------------------------------mno
    ------------------------------Broncos
    ------------------------------------------------------------asq
    ------------------------------------------------------------daff
    This hierarchical structure has a couple of layers, so I don't know how I can feasibly do it. I have tried to look at making hashmaps on top of each other so that as I iterate thru the data, I can check for the existence of a key, and if it exists, get the key and add to it.
    Does anyone know a good way to do this? Code samples would be appreciated!!!
    Thank you!

    Hi Jason,
    I guess you wouldn't want to use Swing components or JTree unless your app has some GUI and even then you would want to look for some other structure than say JTree to represent your data.
    You have got plenty options one is that of using nested HashMaps. You could just as well use nested Lists or Arrays or custom objects that represent your data structure.
    I don't know why you should exclude XML. There is the question anyway how you get your data in your application. Is a database the source or a text file? Why not use XML since your data seems to have a tree structure anyway and XML seems to fit the bill.
    An issue to consider in that case is the amount of data. Large XML files have performance problems associated with them.
    In terms of a nice design I would probably do something like this (assuming the structure of your data is fixed):
    public class Leagues {
        private List leagues = new ArrayList();
        public FootballLeague getLeagueByIndex(int index) {
            return (FootballLeague)leagues.get(index);
        public FootballLeague getLeagueByName(String name) {
            // code that runs through the league list picking out the league with the given name
        public void addLeague(FootballLeague l) {
            leagues.add( l );
    }Next you define a class called FootballLeague:
    public class FootballLeague {
        private List teams = new ArrayList();
        private String leagueName;
        public FootballTeam getTeamByIndex(int index) {
            return (FootballTeam)teams.get( index );
        public FootballTeam getTeamByName(String name) {
            // code that runs through the team list picking out the team with the given name
        public void addTeam(FootballTeam t) {
            teams.add( t );
        public void setTeamName(String newName) {
            this.name = newName;
        public String getTeamName() {
            return this.name;
    }Obviously you will continue defining classes for Players next following that pattern. I usually apply that kind of structure for complex hierarchical data. Nested lists would be just as fine, but dealing with nested lists rather than a simple API for you data structures can be a pain (especially if you have many levels in your hierarchy);
    Hope that helps.
    The Dude

  • Hierarchical data maintainance

    Hello,
    I have a table (Parent - Child).
    There is a requirement to maintain this table, thats the hierarchy of the oraganisation.
    So, every quater they will be updating the table.
    They will be importing the data through an excel and in that excel there are 3 action items,
    => Insert, Update and Delete (logical delete).
    CREATE TABLE PARENT_CHILD_TBL
       ( "ID" VARCHAR2(6 BYTE) NOT NULL ENABLE,
    "ID_DESC" VARCHAR2(200 BYTE),
    "ID_LEVEL" VARCHAR2(200 BYTE),
    "PARENT_ID" VARCHAR2(200 BYTE)
    For Update:
    Any ideas, What all validation can come for an updation of an hierarchical data in general.
    Like
    = how to derive the level value at database side when the id is updated to some other level.
    = How to maintain the relation.
    A -> B -> D ( A is the grand parent here).
    A -> C
    eg: if B is updated as parent node of A, then we should throw error (cyclic data).
    Any more validations for hierarchical data, anybody can suggest and the way to go for it will be helpful.
    Thanks !!

    Hi,
    You can use the LEVEL psudo-column in a CONNECT BY query:
    SELECT  p.*
    ,       LEVEL
    ,       CASE
                WHEN  TO_CHAR (LEVEL, 'TM') = id_level
                THEN  'OK'
                ELSE  ' *** BAD ***'
    END     AS flag
    FROM    parent_child_tbl  p
    START WITH  parent_id  = '0000'
    CONNECT BY  parent_id  = PRIOR id
    Output from the sample data you posted (where all the level_ids are correct):
                              PARENT
    ID    ID_DESC    ID_LEVEL _ID            LEVEL FLAG
    A     ROOT       1        0000               1 OK
    B     CHILD1     2        A                  2 OK
    D     SUB CHILD1 3        B                  3 OK
    C     CHILD2     2        A                  2 OK
    If you only want to see the rows where id_level is wrong, then you can use LEVEL in a WHERE clause.
    Maybe you shouldn't bother manually entering id_level at all, and just have a MERGE statement populate that column after all the other data is entered.
    Why is the id_level column defined as a VARCHAR2, rather than a NUMBER?
    Given that it must be a VARCHAR2, why does it need to be 200 bytles long?

Maybe you are looking for

  • Color Buttons in Captivate 5

    Is there any way to change the color of a button in Captivate 5? I see the text options but nothing for the button itself; does this mean buttons will need to be imported or created outside of Captivate?

  • RE: List View & Disappearing Columns

    I have the same problem. After a change in my ListView properties I loose some columns, usually the first and last but it's mostly random. I had Forte completely crash couple of times after I run the app. ! I am also using ImageData in my subclass Di

  • I have residual links from an "unauthorized" installation that I cannot get rid of. I uninstalled that copy and re-installed the appropriate version. HELP

    I am getting links to other sites, specifically adobe, that want me to install a certain version, yet Firefox doesn't recognize it. I have tried to delete that link, which comes up on my Spymaster scan and malware scans. I reset my computer with Fire

  • Default value for hyperlink

    I setting up an Access 2010 database. Some of the fields are hyperlinks to document and folders To save some time I thought I'd use the Default Value field in the Hyperlink fields and set a URL e.g. \\serverx\directory\folder Once saved when I create

  • SOA10134+WLS+DB Adapter error:waiting for localConvId

    Hello Experts, I'm migrating the project implemented on 0c4j+1033 to 1034+wls one bpel process does select count(*) from table and if count >0 then it runs select col1,col2.. from table it is returning count =6 and select query is returning empty var