I have a hierarchical set-up going on a table using the whole START WITH and CONNECT BY clauses, which I am using to set-up a vertical-aligned menu system that can expand out to the right, depending on if a menu option has children and the total number of Levels. Also, as part of the menu option, if a parent has children, I also display a '>' symbol to specify this.
My question is, I am using CONNECT_BY_ISLEAF to determine whether a menu option is a leaf or not but I also have a column in my hierarchical table that specifies whether the menu option is active or not.
So when I have a case of a parent/child set-up in my menu, so that the ISLEAF value for Parent is 0 and Child is 1, but I have actually made the Child menu option inactive, my '>' symbol still displays at the parent level, even though the child record for this parent is inactive.
Any idea how I can check this alongside with the CONNECT_BY_ISLEAF value, to prevent the '>' symbol appearing even though this parent menu option has an inactive child record?
Basically want something that, if a child record exists based on ISLEAF value but child record is inactive, then ignore this leaf record and pretend it doesn't actually exist.
SELECT *
FROM table
CONNECT BY
parent = PRIOR id
AND active = 1
This will select a child only if it's active, if that's what you want.
Note that this query will return CONNECT_BY_ISLEAF = 1 for the items that do not have active children, and they will probably be treated as endpoints in your design.
Related
I am currently helping design a business case form in ACCESS 2013 for our department's product managers to facilitate them submit business cases and store data.
There is one subform on the parent form, which displays all SKUs associated with the business case in datasheet view, as well as their statuses (one SKU might be in stage 1, another in stage 2), and the parent/child form are linked by case ID. That is to say one case ID is associated with many SKUs. What I want to do is to update a field value (case status) on parent form only when all SKU statues are updated to stage 3. If one SKU is stage 3 but another one is in stage 2, then don't update the case status. I googled a lot however there doesn't seem to be a solution I can find online. Could anyone please help me?
Should not save this calculated value to table. Just calculate when needed.
A textbox on subform footer can have expression to count records where stage is not 3.
=Count(IIf(Stage<>3,1))
Textbox on main form can reference the subform textbox.
=IIf([subform container name]!tbxStageCount > 0, "Incomplete", "Complete")
I have about 4 attributes in Race dimension as shown in blow
dimension name is Race
1)Race
2)RACE DESC
3)RACE KEY
4)RACE SHORT NAME
when go to cube browse and right click on Race dimension and select add query
as below
1)when i drag Race dimension to browser data panel it showing default Race Attribute data
2)i want show RACE DESC data only
3) at the same time i drag the RACE DIMENSION in Filter panel
4) i want show RACE DESC Attribute only
5) i don't want set attributehierarchyvisible =false
how do i achieve my above requirement
Thanks for the help
Create your own user's hierarchy and place it on the 1st place in dimension hierarchies part of screen. This will let SSAS to use it.
Here Report Date hierarchy is selected by default.
And Product Categories on the image below:
UPDATE
Here is detailed explanation:
Now you have 5 flat hierarchies and server takes first alphabetical one by default, like this (Count is measure here):
To fix this, you need to disable attributes hierarchy, which you want to be selected by default:
Than rename attribute, to be able to create user's hierarchy with the same name (so for users this will be identical as previous flat attribute hierarchy):
Finally, process this dimension again, and when you drag dimension, it will show your first user's hierarchy, which is State in our case.
Hope this helps.
UPDATE-2 (New example with races)
To achieve this, you need to do the same as described in UPDATE #1:
Rename RACE DESC to some other name (e.g. RACE DESC Attr) and disable it's hierarchy visibility by setting attributehierarchyvisible = false
Create user's hierarchy on this attribute with desirable name: RACE DESC
Process dimension.
That's all. Now default attribute will be RACE DESC. It's hierarchy is not disabled, just it's showing priority is changed to be the 1st one.
scenario is like
customer_profile
parent child
100 101
100,101 102
100,101,102 103
i have a problem i have chaining system in my asp.net website,when a record has inserted each time it's parent is selected by dropdown list, i want it'll go to various level it's parent of parent's will be concatenated thru sql.
please tell me how to design stored procedure for this chaining.
Thanks in adv
I have a situation where I am going to have a fairly large dataset that I need to represent as a tree hierarchy within Oracle APEX v4.2.2. The dataset might be up to 6000 records with a depth of 5 levels.
Based on another thread, what I am looking at doing and this being the reason of this question, is initially within my tree query, I will only display up to 2 levels, i.e.:
WHERE level <= 2
My question is, while displaying my tree hierarchy of level <= 2, I want to then allow the user to click on a level 2 node, which would be fed somehow back into my tree hierarchy query and then basically display from a level 2 node down the tree to say the next 2 levels - now displaying from level 2 to level 4 and then continue in the same fashion.
Obviously I will also need a means of getting back to the top level of my tree from any lower levels being displayed at the time - say from level 4.
I am interested in how to best tackle this - I was also thinking whether I display a popup window of the next set of tree hierarchy data.
I think 6k records is still manageable by Javascript, so probably the easiest way would be to load the entire tree and collapse it onLoad with a Javascript/JQuery dynamic action.
Otherwise you can also try storing the desired level/key on a Hidden Page Item, build the tree hierarchy query using the value from this page item and just refresh the area with a dynamic action onClick.
I've developed an application that populates a treeview from hierachical data in a database.
I've designed it to use lazy-loading so it only gets the child nodes when a node is expanded.
My problem is that obviously I don't know if a node has children unless I make a call to the database and look. Currently I have implemented a dummy child node, so that the [+] icon appears for all nodes, I then remove this dummy node and get the real child nodes in the BeforeExpand event.
This means I get a [+] icon for nodes that don't have child nodes, so the user clicks the expand icon and there's nothing show which looks a bit shoddy.
What is the preffrred method for handling child nodes in a lazy-load treeview? If I make a call to the database to see if there are child nodes then I might as well just load the child nodes and forget about lazy loading right?
One thought I had was to store a 'HasChildren' flag in the database, so I can selectively create my dummy child node only for the nodes that actually do have child nodes.
Sorry for rambling on, I'm very interested to see what other people think...
When you make a call, check for children along with the node data:
SELECT tp.*,
(
SELECT 1
FROM table tc
WHERE tc.parent = tp.id
LIMIT 1
) AS has_children
FROM table tp
You don't have to count, it may be long.
Just check that at least one child exists.
change your initial query to return all the same data, but also a count of children. when the children count is not zero show the [+]. post your schema and query for help getting the count
My preferred solution to this problem is to implement pre-ordered tree traversal on your set of hierarchical data. See http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ for an example implementation.
The point is that if you maintain a left and right value for each node, then if the left value and right value differ by more than one, that node has children.
The only notable downside of this approach is that you have to actively maintain those left and right values when altering the structure of the nodes.