How to perform account on a Table hierarchical Oracle based on the Parent link
Hello
I have the following to Oracle 11 g R2 hierarchical table definition:
Table Name: TECH_VALUES: ID, GROUP_ID, LINK_ID PARENT_GROUP_ID, TECH_TYPE
Above the hierarchical table definition, some examples of data might look like this:
ID GROUP_ID LINK_ID PARENT_GROUP_ID TECH_TYPE
------- ------------- ------------ -------------------- --------------
1 100 LETTER_A 0
2 200 LETTER_B 0
3 300 LETTER_C 0
4 400 LETTER_A1 100 A
5 500 LETTER_A2 100 A
6 600 LETTER_A3 100 A
7 700 LETTER_AA1 400 B
8 800 LETTER_AAA1 700 C
9 900 LETTER_B2 200 B
10 1000 LETTER_BB5 900 B
12 1200 LETTER_CC1 300 C
13 1300 LETTER_CC2 300 C
14 1400 LETTER_CC3 300 A
15 1500 LETTER_CCC5 1400 A
16 1600 LETTER_CCC6 1500 C
17 1700 LETTER_BBB8 900 B
18 1800 LETTER_B 0
19 1900 LETTER_B2 1800 B
20 2000 LETTER_BB5 1900 B
21 2100 LETTER_BBB8 1900 B
Keeping in mind that there are only three Types of technology, i.e. A, B and C, but could not span on different LINK_IDs
, how can I do a count on these three different TECH_TYPEs
based solely on the ID of parent link where the parent group id is 0 and there are children below them?
NOTE: It is also possible to have parents in dual link ID such as LETTER_B and all values of children but different group ID.
I'm basically after a table/report query that looks like this:
Link ID Tech Type A Tech Type B Tech Type C
-------------- ------------------- -------------------- -------------------
LETTER_A 3 1 1
LETTER_B 0 3 0
LETTER_C 2 0 3
LETTER_B 0 3 0
Be hierarchical and my table can consist more of 30 000 files, I must also ensure that performance to produce the report above shown here query is fast.
Obviously, in order to produce the report above, I need to gather all necessary County outages based on TECH_TYPE
for all parents of the link id where the PARENT_GROUP_ID = 0
and store it in a table according to the guidelines of this report layout.
Hope someone can help with maybe a combined query that performs the counties as well as stores the information in a new table called LINK_COUNTS, which will be based on this report. Columns of this table will be:
ID,
LINK_ID,
TECH_TYPE_A,
TECH_TYPE_B,
TECH_TYPE_C
At the end of this entire requirement, I want to be able to update the LINK_COUNTS table based on the results returned by the sample data above in a SQL UPDATE transaction as the link ID parent top-level already exists within my table LINK_COUNTS, just need to provide values for breaking County for each parent node link , i.e.
LETTER_A
LETTER_B
LETTER_C
LETTER_B
using something like:
UPDATE link_counts
SET (TECH_TYPE_A,TECH_TYPE_B,TECH_TYPE_C) =
(with xyz where link_id = LINK_COUNTS.link_id .... etc
Which must match exactly the above table/report
Thank you.
Tony.
Hi, John,.
Thanks for posting the sample data.
John Spencer wrote:
... If you need to hide the ID column, then you could simply encapsulate another external query around me. ...
Or simply not display the id column:
Select link_id, -id,
Count (case when tech_type = 'A' end then 1) tech_a.
Count (case when tech_type = 'B' then 1 end) tech_b,.
Count (case when tech_type = "C" then 1 end) tech_c
of (connect_by_root select link_id link_id,)
the connect_by_root ID, tech_type
of sample_data
Start with parent_group_id = 0
connect prior group_id = parent_group_id)
Link_id group, id
order by link_id, id;
Same results, using SELECT... PIVOT
WITH got_roots AS
(
SELECT CONNECT_BY_ROOT link_id AS link_id
Id CONNECT_BY_ROOT ID
tech_type
OF sample_data
START WITH parent_group_id = 0
CONNECT BY PRIOR group_id = parent_group_id
)
SELECT link_id, tech_a, tech_b, tech_c
OF got_roots
PIVOT (COUNT (*)
FOR tech_type IN ('A' AS tech_a
'B' AS tech_b
'C' AS tech_c
)
)
Id ORDER BY link_id
;
Tags: Database
Similar Questions
-
How to upgrade the parent table and child by updating the parent table
I have a parent EMPLOYEE table that includes columns (sysid, serviceno, employeename...) sysid is the primary key, serviceno is the Unique key and I have DEPENDENT child table includes columns (sysid, employee_sysid, name, date of birth...) there still SYSID is a primary key for the table of dependants, employee_sysid is a foreign key in the EMPLOYEE table.
Now I want to change SYSID (with the help of the sequence) in the EMPLOYEE table that they want an update in the table of people dependent
Note: I have 10000 records in the EMPLOYEE table as I have 5 more children tables that need to update new SYSID.
Please help mefirst disable FOREIGN KEY constraints.
You can update Parent and child record with the help of the trigger.
Here I give you an examlpe... It can help u.create a parent (id number primary key, name varchar2 (100)) table
/
create table child_1 (primary key id, p_id number number, date of birth, date)
CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
/
create table child_2 (key primary id, p_id2, addr varchar2 number number (1000))
CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
/Insert some test data for the parent tables and children.
change the constraint to disable child_2 table FK_id2
/
change the constraint to disable child_1 table FK_id2
/CREATE OR REPLACE TRIGGER delete_child
BEFORE parent UPDATE ON
FOR EACH LINE
BEGIN
UPDATE CHILD_1
P_ID =:NEW.ID SET
WHERE P_ID =:OLD.ID;
UPDATE CHILD_2
SET = P_ID2: NEW.ID
WHERE P_ID2 =:OLD.ID;
END;
/then Upadte parent table primary key col and check the children tables.
do enable constraints... -
The Master Table column updated based on the sum of column Table detail
With the help of JDev 11.1.1.6.I have a master-detail table based on a link to BC.
The main table has a column that displays an InputText or an OutputText, based on the value in another column.
If the InputText is displayed, the user can enter a value and the database will be updated with that value.
If the OutputText is displayed, it must be a sum of a column in the secondary table. Also, this value will be written in the database.
Question:
How can I fill the OutputText in the main table with the sum of the values in a column in the secondary table?
The detail table column is a manually entered InputText field.
Thank you.
Create a spike in the main table and write in its expression as follows - DetailVoAccessorName.sum ("ColumnName");
This will calculate the sum of column table detail and then you can set the value of the transient attribute to attribute DB on backup operation
Ashish
-
Join between tables header &; detail based on the age and group
To find the amount of the age and the group in the table of detail based on age & group_id in header?
Example: Take the seq_id = 1 mind, it has age = 60 & group_id = 23 (23 months).
In the detail table xx_detail, the age column represents the age of the person (0-65 represents the age 0-65 and so on).
If the age is null, while the rank indicates the Group (0-12 represents the group between 0-12 months). If the age is not null, then the Group 1, group 2, group 3 that data amounts.
So now I must get the amount as 240 (like my seq_id header = 1, age = 60, group_id = 23, as it is covered by group age & 13-59 0-65). So I need a SQL to find the exact amount in detail based on the header record. We must go to settings & group_id age and get an amount of detail tables. Can anyone provide input how to achieve this in the most simple.
- SQL > select * from v$ version
- 2.
- BANNER
- --------------------------------------------------------------------------------
- Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
- PL/SQL Release 11.2.0.3.0 - Production
- CORE Production 11.2.0.3.0
- AMT for Linux: Version 11.2.0.3.0 - Production
- NLSRTL Version 11.2.0.3.0 - Production
- SQL > xx_header desc ;
- Name Null? Type
- ----------------------------------------- -------- ----------------------------
- SEQ_ID VARCHAR2 (6)
- AGE NUMBER
- START_DATE DATE
- GROUP_ID NUMBER
- SQL > select * from xx_header;
- SEQ_ID AGE START_DATE GROUP_ID
- ---------------- ------ ------------------ ---------------
- 1 60 1 JANUARY 12 23
- 2 89 1 JANUARY 12 23
- 3 95 1 JANUARY 12 23
- SQL > xx_detail desc ;
- Name Null
- ----------------------------------------- -------- ----------------------------
- SEQ_ID VARCHAR2 (10)
- AGE VARCHAR2(10)
- GROUP1 VARCHAR2 (10)
- GROUP2 VARCHAR2 (10)
- GROUP 3 VARCHAR2 (10)
- SQL > select * from xx_detail;
- SEQ_ID AGE GROUP1 GROUP2 GROUP3
- ---------- ---------- ---------- ---------- ----------
- 1 0-12 13-59 60-126
- 1 0-65 120 240 300
- 1 66 - 135 100 80 400
-
How to dynamically change values lov to an article based on the button
Hello
How to dynamically change the value list of an article based on the button create and apply the changes
I have the column type of transaction that lov with values as inward, BACK inward outward, outward in the form based on the table...
in design mode
I need list to the OUTSIDE inward, in the type of transaction oly column...
in update mode
I need the list of BACK inward, BACK outwards in the type of transaction oly column...
Kind regards
Pavan
Maybe something like that for a dynamic LOV
select label d, label r from select 'inward' label , 'create' chk from dual union all select 'outward' , 'create' from dual union all select 'inward return' , 'update' from dual union all select 'outward return', 'update' from dual ) where (:P1_ID is null and chk = 'create') or (:P1_ID is not null and chk = 'update')
-
ADF Table cell color based on the value of this field
Dear all,
I want to create a table for our new application that contains a table that is used to represent the data in a table or matrix format.
and each cell of the table should be filled with a color of three colors, based on the value belongs to who will for example: (1-8-> green, 9-20 - yellow etc.).
I don't know how to implement this. Help, please...
RognardPlease post in the subforum that is appropriate for your question.
http://forums.Oracle.com/forums/Ann.jspa?annID=599
This blocking thread
-
How could put editable report column as read only based on the other domain
Hello world
I'm new to APEX. I have a modifiable tabular report (SQL query). When I choose the column (which is a selection list) of a certain value, I want column B to be read-only (depending on the result of an another SQL described below). It doesn't seem to be a READ ONLY section in the type of tabular report where I could put my SQL condition.
In other words, "column B" must be read only based on SQL returning following true or Exists:
Thus, to determine if column B is ready only, I need the following logic:
SELECT 'x '.
of tab1
where key = (value of column A)
and the flag = "Y".
Any help would be greatly appreciated!
Thank you
FrançoisYou can only do so if your tabular presentation is a manually created. In this example, it shows how to set this property:
http://Apex.Oracle.com/pls/OTN/f?p=31517:170
You can use a case statement to set this property for specific lines.
SELECT empno, CASE WHEN ename LIKE 'A%' THEN apex_item.text (34, job, 80, 100, 'style="width:170px" readonly="readonly"', 'f34_' || '#ROWNUM#' ) ELSE apex_item.text (34, job, 80, 100, 'style="width:170px"', 'f34_' || '#ROWNUM#' ) END job FROM emp
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
------------------------------------------------------------------- -
Update of custom table and column based on the number of lines inserted in it.
Hello
I have a XX_TDP_DT custom table that has a column ID_processus.
User will be be download data in the XX_TDP_DT table, but they insert any value into ID_processus.
Say if the entered data are 1000 lines.
I need to process these 1000 rows in batches, so I want to have 1 for 1 to 200 rownum = ID_processus, ID_processus = 2 for rownum 201 to 400 and so on.
How can I achieve this, any suggestions?
Database: 10g
Thank you.You can also use NTILE to do this, see:
Re: Divide also extracted almost lines and assign a group
http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:47910227585839 -
Find the name and the table constraint type based on the name of the field
I have a field name or a column with me... I want to find the name of the table is a primary key... Any request to make this work so that the running costs are low...
Currently, I mix dba_constraints and ALL_TAB_COLUMNS to get this... is possible to extract the data of a process cost effective single table/any other is appreciated
You must include the USER/ALL_CONSTRAINTS with USER/ALL_CONS_COLUMNS to achieve your desired results. For your specific condition, you can try this query.
Select constraint_name
column_name
de)
Select c.constraint_name
cc.column_name
count on column_count (c.constraint_name score) (cc.column_name)
from user_constraints c
Join user_cons_columns cc
on c.constraint_name = cc.constraint_name
where constraint_type = 'P '.
)
where column_name = 'EMPNO '.
and column_count = 1;
I used USER_CONSTRAINTS and USER_CONS_COLUMNS. If you use ALL or DBA dictionary table add join OWNER condition as well.
-
How can I get my submenu/child pages to appear under the parent url
I want to parent my submenu/child to come under the url pages.
Example parent URL: www.mywebsite.com/music-lessons.html
With the submenu/child: www.mywebsite.com/music-lessons/guitar.html
Currently, even if it is a submenu/child page it appears as follows: www.mywebsite.com/guitar.html and the parent url does not appear.
Thank you
Hi Karen,.
This may be possible with a Muse site as default Muse publishes all the pages in the root folder.
You will need to publish several site Muse to subfolders on your directory in order to get such results.
Kind regards
Akshay
-
How to create table selectable line or not based on the value of the line
Hello.
JDeveloper 11.1.1.2
Is it possible to make a selectable table row or not based on a value in the line.
That is to say. lets say that the row contains a Boolean LOCKED = TRUE.
This line should not be selectable.
A line whose value LOCKED = FALSE should be selectable.
/ ErikErik,
No particular reason to disable a selection of lines for a particular line? If I'm an end user, I would be clicking on the same line of thought again and again my mouse does not ;) (call me dumb :)). How do you differentiate this line (using inlineStyle / styleClass) based on the value of line? In addition, you can disable the other buttons when a row with a particular value is selected (so that the user knows that the selected line is not treatable).
Arun-
-
2 definitions of view based on the value of the table
Hi all
Is it possible to have 2 different definitions of each entry of 2 base tables display different, based on the value of the table?
We have 2 tables with similar columns, one with historical and other data was only the latest / greatest according to yesterday (it is populated by ETL from mainframe). Changes made by the java application online is now going into the table containing historical data immediately, but edits made in mainframe comes to the table with the data current next day.
There are 2 products, an is based on the last and largest of the historical table based on cre date and date of mod and other product relies on the table with the current data (not historical).
Tried using joins for these two tables but the performance wasn't good and each product needs table data alone, and so I wanted to eliminate joins.
We wanted to use the same name for the view from the metadata using the shared functionality based on the name of the view.
Is there a way define a view under certain conditions?
It is:
If the value for a particular parameter is 0 then
Select c1, c2, c3 of < historical table > other
Select c1, c2, c3 of < no history table >
Any ideas?You are looking for something like this?
Re: how to pass parameters in a view -
you want to know how to block the ophcrack from running, my child uses this to get my password and in the parental controls in vista. I have 3 accounts going 2 for children and one for the parents/administrator. I found ophcrack in several places on the computer. any help would be greatly appreciated
The only question the idea of Malkeleah, that is when you put a password on BIOS, all you need to do is pop the battery from the motherboard and the password is gone. Faronics has in some programs such as anti-executable and a few other programs that may block the name or ID of a process and prevent it from running (some antiviruses have that option, such as Avast, but usually is a pain in the ass to configure)
-
Table is not fetch all the data of the VO at a time?
Hello world
My version of Jdev is 11.1.2.3.0.
I developed page ADF that has a single Table that should show all the data in the original Version at the same time.
The table has vertical and horizontal scroll bars. And the VO has more than 900 documents.
The question is, at the start when loading the page table shows 20-25 records then when I try to scroll down and then the data is going to look this day there ("retrieving data" message) by which its takes a long time to see the data because its extraction at the time where I scroll down.
How can I avoid this?
How will I be able to retrieve all data from VO (all 900 records) by which when I scroll data should not look at this time?
And also increases the size of the table and is based on the data when I scroll down.
How can I avoid this?
How can we fix the size of the table regardless of the content?
All suggestions will be really useful...
Thank you.The message «Retrieving data...» "is issued by the client component of table rich user interface when it retrieves data of the server-side model component lines in its local buffer of lines. Even if the server-side model component has recovered all the rows from the database (e.g. VO has recovered all of the rows from the database in the cache of the VO), the client component of table UI does not download all of them locally, but it downloads as needed into portions whose size is controlled by the attribute 'fetchSize' of the table. By default, the 'fetchSize' attribute is set to the value of the property "rangeSize' of the corresponding mandatory ADF iterator (whose default value is 25). In this way, if you scroll to the bottom of the table of the UI after the 25th row, the table would download the next set of 25 lines of its components side server model (and it then displays the message "retrieving data... ('') and so on.
If you want to avoid downloading frequent of the next rowset of the component side server model to the customer table component user interface, you can set attribute 'fetchSize' of the table to a more fixed, for example:
In this way, only the client user interface table would download locally 1000 lines (if there are so many existing lines, of course) and it won't download more rows until you scroll the table after the 1000th line (when it would download a next series of 1000 lines).
Be wise when the setting 'fetchSize' of the table to a large number, because more the 'fetchSize', greater would be the size of HTTP, the longer answer response would be and more memory at the customer level would be consumed for the customer table buffer. Note that-1 (for example "get all") is not a valid value for the attribute 'fetchSize '. If you set it to-1, it will default to 25.
Dimitar
-
How to divide the resultset SQL based on the data in the form of scenarios?
Hello
I need to develop a query that should be divided into scenarios
Ex:
Scenario 1: If a product is sold to the United States and charged in the United Kingdom
Scenario 2: If a product is sold to the United Kingdom and charged in the United States
Scenario 3: If a product is sold and invoiced to the United States
Scenario 4: If a product is sold and invoiced to the United Kingdom
Based on 1 how to divide and provide SQL result to users based on the scenarios?
Ex: Result should show all the data, saying that the result set is in scenario 1, etc..,.
Please advice
Thank you
user12048986Hello
You can use an expression BOX to classify each line:
CASE sold_country || ' ' || billed_country WHEN 'US UK' THEN 1 WHEN 'UK US' THEN 2 WHEN 'US US' THEN 3 WHEN 'UK UK' THEN 4 END AS scenario_num
If sold_country or billed_country is anything except 'UK' or 'US', then the above expression returns null.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
Hello
Is this the same question you asked 3 days ago
https://forums.Oracle.com/thread/2606197
?
Whether it is or not, validate the information requested in this message, which is also in the FAQS of the Forum:
https://forums.Oracle.com/message/9362002
If it's the same question, do not post a new thread. Mark it as "Answered" immediately and continue in the original thread.
Maybe you are looking for
-
Majority of the audio or video does not work in the timeline?
I started to edit a music video the other day after collection of images and its import. Everything was good, audio and video has worked... Opened yesterday and when I fly over my clips and audio sequences, it doesn't seem to work (but works fine in
-
Email Security issues/Support?
My back "story"... So I got a second hand iPhone 5s in perfect condition about 2 weeks ago but cannot make purchases on the iTunes/App store because I am asked to enter the answer to the 2 security questions. This (I'm sure) is normal on a new device
-
I have a forum site that I visit at least a few times a day and I told both the site and the firefox popup to remember my username and password. He used to save, but it stopped working in recent weeks. When I go to my saved usernames and passwords (T
-
Cannot use HDD recovery but I would like to restore to factory settings
I caught a virus at one point and restarted the laptop... I want to restore the laptop to factory settings and when I clicked f8 to make the options of recovery, but it doesn't give me an option to reset the hard drive I need... When I did my backup
-
Mein Server isst ausgelastet. has was kann ich tun
Hallo, Mein ist ausgelastet und ich komme nicht mehr ins INTERNET Server