Insert the parent/Child records in an xml file...
XML file pasted below:I loaded the xml file in a table called xml_demo that has a column of type xmltype donnees_xml.
The Select to parent record is thus, and it works:
INSERT INTO balit_submissions (balitdoc, documentversion, datetime_from, job_id, status, creation_datetime)
(SELECT 'MOL'
((, to_number(extract(x.xml_data,'/MolDocument/DocumentVersion/@v'))
(, to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
"yyyy-mm-dd HH24" T"")
123456
"CREATED",
NULL VALUE
OF xml_DEMO x WHERE
(([existsnode(x.xml_DATA,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1).
/
Having problem creating records child. From this file, I expect to create 3 folders.
insert into balit_energy_blocks
(
SO_ID,
DATETIME_FROM,
DIRECTION,
BLOCK_NUMBER,
ENERGY,
LAST_SUBMIT_DATETIME,
PRICE_POUNDS,
PRICE_EUROS,
BALIT_REF,
STATUS,
LAST_EDIT_DATETIME,
MOL_REASON,
ACQUIRING_SO_AREA)
(SELECT 'TEN'
(, to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
"yyyy-mm-dd HH24" T"")
(, DECODE(extract(x.xml_data,'/MolDocument/MolTimeSeries/Direction/@v'),'AO1','Up','Down')
(, to_number(substr(extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))
((, to_number(extract(x.xml_data,'/MolDocument/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
sysdate
, null - price books
, null - price euro
(, extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v')
"PRESENTED".
, "A96.
NULL - acquisition of area
sysdate
OF xml_DEMO x WHERE
(([existsnode(x.xml_DATA,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1).
/
For example, there are 3 ContractIdentification tags. Example 1:
< ContractIdentification v = "RTE_20100331_1500_16" / >
I expect this selection to snatch the last issue of this string. In this case, 16.
The selection was:
TO_NUMBER(substr(extract(x.xml_DATA,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))
The result I got was:
16RTE_20100331_1500_20NG_20100331_1500_6
All values of contractident are concatnated and returns posted 19 go.
Can someone help me to extract the last number of each tag value of ContractIdentification and create the 3 files
Thank you
James Sathiaraj
<? XML version = "1.0" encoding = "UTF-8"? >
< MolDocument DtdVersion = "3" DtdRelease = "0" >
< DocumentIdentification v = "MOL_20100331_1500_1600" / >
< DocumentVersion v = "1" / >
< V DocumentType = "A43" / >
< CodingScheme = v "A01" SenderIdentification = "17X100Z100Z0001H" / >
< SenderRole v = "35" / >
< ReceiverIdentification codingScheme = v "A01" = "10XFR-TEN - Q" / >
< ReceiverRole v = "A04" / >
< CreationDateTime v = "2010-03 - 31 T 14: 10:00Z" / >
< ValidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< codingScheme domain = "A01" v = "10YDOM-1001A001A" / >
< MolTimeSeries >
< ContractIdentification v = "RTE_20100331_1500_16" / >
< ResourceProvider codingScheme = v "A01" = "10XFR-TEN - Q" / >
< CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
< ConnectingArea codingScheme = v "A01" = "10YFR-TEN - C" / >
< AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
< BusinessType v = "10" / >
< BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< MeasureUnitQuantity v = "MAW" / >
< v currency = "EUR" / >
< MeasureUnitPrice v = "MWH" / >
< v direction = "A02" / >
< MinimumActivationQuantity v = "50" / >
< v status = "A06" / >
< period >
< v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< resolution v = "PT60M" / >
<>interval
< v pos = "1" / >
< v Qty = "50" / >
< character v = "50.45" / >
< / interval >
< / period >
< / MolTimeSeries >
< MolTimeSeries >
< ContractIdentification v = "RTE_20100331_1500_20" / >
< ResourceProvider codingScheme = v "A01" = "10XFR-TEN - Q" / >
< CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
< ConnectingArea codingScheme = v "A01" = "10YFR-TEN - C" / >
< AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
< BusinessType v = "10" / >
< BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< MeasureUnitQuantity v = "MAW" / >
< v currency = "EUR" / >
< MeasureUnitPrice v = "MWH" / >
< v direction = "A02" / >
< MinimumActivationQuantity v = "50" / >
< v status = "A06" / >
< period >
< v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< resolution v = "PT60M" / >
<>interval
< v pos = "1" / >
< v Qty = "50" / >
< character v = "50.48" / >
< / interval >
< / period >
< / MolTimeSeries >
< MolTimeSeries >
< ContractIdentification v = "NG_20100331_1500_6" / >
< ResourceProvider codingScheme = v "A01" = "10X1001A1001A515" / >
< CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
< CodingScheme = v "A01" ConnectingArea = "10YGB - A" / >
< AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
< BusinessType v = "10" / >
< BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< MeasureUnitQuantity v = "MAW" / >
< v currency = "EUR" / >
< MeasureUnitPrice v = "MWH" / >
< v direction = "A01" / >
< MinimumActivationQuantity v = "50" / >
< v status = "A06" / >
< period >
< v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
< resolution v = "PT60M" / >
<>interval
< v pos = "1" / >
< v Qty = "50" / >
< character v = "17.0" / >
< / interval >
< / period >
< / MolTimeSeries >
< / MolDocument >
Hello
The result I got was:
16RTE_20100331_1500_20NG_20100331_1500_6
In the query have you tried, access you a single record if you can not expect to get three rows of "magic". The EXTRACT function works as planned, it retrieves the nodes required, but the result is always a fragment of XML (a scalar value).
To achieve your goal, you must divide the sequence MolTimeSeries in relational lines.
Two similar solutions are possible, XMLTable (10gr 2 and more) or Table/XMLSequence.
In your other post, you mentioned db version 10.1, so I guess we go with XMLSequence:
SELECT 'RTE'
,to_date(substr(extractvalue(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),'yyyy-mm-dd"T"hh24:mi')
,decode(extractvalue(x2.column_value,'/MolTimeSeries/Direction/@v'),'A01','Up','Down')
,to_number(regexp_substr(extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v'),'\d+$'))
,to_number(extractvalue(x2.column_value,'/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
,sysdate
,null
,null
,extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v')
,'SUBMITTED'
,'A96'
,null
,sysdate
FROM xml_demo x,
table(
xmlsequence(
extract(x.xml_data, '/MolDocument/MolTimeSeries')
)
) x2
WHERE existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1;
Also note the use of instead of the ordinary SUBSTR REGEXP_SUBSTR because he has not worked for "NG_20100331_1500_6".
Hope that helps.
Published by: odie_63 on June 24, 2010 21:18 - comment added regexp
Tags: Database
Similar Questions
-
Default filters that users can delete (in the parent/child Setup)?
Is it possible in Latitude 2.2.2 to have filters (filters of the range, refinement filters etc.) applied by default (which means that users see these filters when they log-in), but they can also remove (using bread crumbs portlet) if they wanted to? We tried to use the source of data (JSON) filters (using 'baseFunctions' setting) where we have a parent/child Setup, but it seems these filters cannot be removed once applied. Note that filters can be removed if we do not have a parent/child relationship between the data sources, but as soon as we introduce a parent/child relationship between the data sources (which we need), the GET of sticky filters and cannot be deleted. Any reason why the parent/child relationship causes the filters becoming sticky? Any way (alternate) to reach what we want?I think that it is a known problem (LSTUDIO-5088) and there could be a fix for this. You can contact technical support to obtain the fix.
Dave
-
Simulate the 1 - N N - N relationship using the Parent-child structure
Hello
I have a 1-N relation between SKILL tables and the USER, which means 1 skill can be applied to multiple users. A jurisdiction may have a parent jurisdiction, which means that a ParentSkill inherits all the privileges of his child.
I would like to simulate a N - N relation between the users and the skills by building a vision that goes through the parent-child relationship. This is possible for the construction?
Current structure:
Favorite exit (the skillid order is not important):|USERID | USERNAME | SKILLID | +-------+----------+----------+ | 1 | Jack | 1 | | 2 | Simon | 1 | | 3 | Fred | 3 | +-------+----------+----------+ |SKILLID | DESCRIPTION | PARENTSKILL | +--------+---------------+--------------+ | 1 | Mechanic | 2 | | 2 | Inspector | 3 | | 3 | Supervisor | null | +--------+---------------+--------------+
|USERID | USERNAME | SKILLID | +-------+----------+----------+ | 1 | Jack | 1 | | 2 | Simon | 1 | | 3 | Fred | 3 | | 3 | Fred | 2 | | 3 | Fred | 1 | +-------+----------+----------+
I hope that answers your needs:
WITH users as ( SELECT 1 as USERID, 'Jack' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL SELECT 2 as USERID, 'Simon' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL SELECT 3 as USERID, 'Fred' as USERNAME, 3 as SKILLID FROM DUAL ), skills as ( SELECT SKILLID,CONNECT_BY_ROOT SKILLID AS ANCESTORS FROM ( SELECT 1 as SKILLID, 'Mechanic' as DESCRIPTION, 2 as PARENTSKILL FROM DUAL UNION ALL SELECT 2, 'Inspector', 3 FROM DUAL UNION ALL SELECT 3, 'Supervisor', NULL FROM DUAL ) CONNECT BY PRIOR PARENTSKILL = SKILLID ) SELECT USERID,USERNAME,ANCESTORS FROM skills, users WHERE users.skillid = skills.skillid /
USERID USERN ANCESTORS ---------- ----- ---------- 1 Jack 1 2 Simon 1 3 Fred 3 3 Fred 2 3 Fred 1
I hope this helps!
-
Stuck on a sql query to search for records that have the same parent child records
Oracle 10 g 2 Enterprise Edition.
Hello
I'm writing a logic to find records in a parent table, who have the same values in a child table.
This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
the problem is that I'm stuck.
Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
many managers.
I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.-- parent table CREATE TABLE manager ( id number primary key, name varchar2(100)); -- child table CREATE TABLE employee ( id number primary key, name varchar2(100)); -- link table CREATE TABLE join_table ( manager_id NUMBER, employee_id NUMBER, CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id), CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id), CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) ); -- Insert some managers INSERT INTO manager (id, name) VALUES (1, 'John'); INSERT INTO manager (id, name) VALUES (2, 'Bob'); INSERT INTO manager (id, name) VALUES (3, 'Mary'); INSERT INTO manager (id, name) VALUES (4, 'Sue'); INSERT INTO manager (id, name) VALUES (5, 'Alan'); INSERT INTO manager (id, name) VALUES (6, 'Mike'); -- Insert some employees INSERT INTO employee (id, name) VALUES (101, 'Paul'); INSERT INTO employee (id, name) VALUES (102, 'Simon'); INSERT INTO employee (id, name) VALUES (103, 'Ken'); INSERT INTO employee (id, name) VALUES (104, 'Kevin'); INSERT INTO employee (id, name) VALUES (105, 'Jack'); INSERT INTO employee (id, name) VALUES (106, 'Jennifer'); INSERT INTO employee (id, name) VALUES (107, 'Tim'); -- Insert the links -- John manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103); -- Bob manages Paul, Simon, Kevin, Jack INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105); -- Mary manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107); -- Sue manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107); -- Alan manages Paul, Simon, Ken, Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107); -- Mike manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103); -- For sanity CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
Answer should be Mike.
If I ask for Manager of Mary, the answer should be Sue.
This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.SELECT DISTINCT m.name AS manager FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND e.id IN ( SELECT e.id FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = 'John') ORDER BY 1;
Any ideas?
BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.What about...
WITH manager_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = :P_MANAGER) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ), all_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ) SELECT a.* FROM manager_list m, all_list a WHERE m.employees = a.employees
Would be easier in 11g, but I do not have a facility here so this is based on 10g.
See you soon
Ben
-
Update the data to uppercase in the parent/child tables
Hi gurus!
In production, we have a table product and that is in reference by many tables making parent child relationship. By mistake, we realized last month some products have been added to lowercase and now we have a request to update all these product codes uppercase so that existing code that use these tables have no impact. Appreciate if you can give an idea about how can I update the existing data in the table parent uppercase as well as child records?
Concerning
SriAre the product code that you need to update what is stored in the tables of children? If Yes, then you must do it in several steps, something like:
Identify the child tables
SELECT table_name, constraint_name FROM user_constraints WHERE r_constraint_name = (SELECT constraint_name FROM user_constraints WHERE table_name = 'PRODUCT_TABLE' and constraint_type = 'P');
Create new product of upper-case code in the product table:
INSERT INTO product_table SELECT UPPER(product_code), other_columns FROM product_table WHERE product_code <> UPPER(product_code);
Update the children tables for caps product codes
UPDATE child1 SET product_code = UPPER(product_code) WHERE product_code <> UPPER(product_code);
Finally, remove the tiny product_table product codes
DELETE FROM product_table WHERE product_code <> UPPER(product_code);
John
-
Get the parent-child hierarchy of column delimited
I've been on this forum once before, and someone helped me, so I hope I can get help again!
4-15-5987');
Thus, the hierarchy is divided on the hyphen. first parent being 4245, then the next value is-4 (including the hyphen) and what follows is - 1, for example
CREATE TABLE REGEXTEST ( ITEM VARCHAR(20)); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-1'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-10'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-11'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-12'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-13'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-14'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59A7'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59D7'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59F7'); INSERT INTO REGEXTEST (ITEM) VALUES ('4245-
I have to be able to bind-1, -4, 4245. Perhaps the simplest is to build a new table with a primary key where it is assigned the id of the parent to the child.
I just can't understand how to divide the individual elements and maintain the hierarchy. As previously mentioned, someone helped me with another part of the problem before where I needed to maintain the entire path of each child with the following query:select nvl(prior item,item) parent, nvl2(prior item,item,null) child from REGEXTEST connect by substr(item,1,instr(item,'-',-1) - 1) = prior item order by child,parent
Now, if I could extrapolate that into a new table:
CREATE TABLE FileHierarchy (ItemID INT NOT NULL PRIMARY KEY, ItemName varchar(50) NOT NULL, ParentID INT NULL);
ItemName is the 4245 or - 4 or - 1 (only) - Yes, including the hyphen.
The ID of the parent-1 would be the ID-4, etc...
Thank you very much in advance!
J.F. Larente
Solution for not having stored the high level:
SQL > select *.
regextest 2
3.POINT LEV
-------------------- ----------
4245 4
4245 4-1
4245 4-10
4245 4-11
4245 4-12
4245 4-13
4245 4-14
4245 4-15
4245 4-15-59 A 7
4245 4-15-59 D 7
4245-4-15-59F711 selected lines.
SQL > with t1 as)
2. Select item
regextest 3
4 Union all the
5 select distinct substr (item, 1, instr(item,'-',1))
6 of regextest
7 ),
8 t2 as)
9. select element,
10 row_number() on id (order by article)
11 from t1
12 )
13. select id,
14 regexp_substr (rtrim (point,'-'), case level when 1 then ' [^-] + $' other '-[^-] + $' end) child.
parentID 15 prior id,
16 regexp_substr (prior rtrim (point,'-'), case level - 1 when 1 then ' [^-] + $' other '-[^-] + $' end) parent
17 of t2
beginning 18 with substr(item,-1) = '-'
19 connect by substr (item, 1, instr(item,'-',-1) - 1) = prior rtrim(item,'-')
20 and article! point prior =
21.ID PARENTID PARENT CHILD
---------- -------------------- ---------- --------------------
1 4245
2 -4 1 4245
3 -1 2 -4
4 -10 2 -4
5 -11 2 -4
6 -12 2 -4
7 -13 2 -4
8 -14 2 -4
9 -15 2 -4
10-59A 7 9-15
11 59 D 7 9 - 15ID PARENTID PARENT CHILD
---------- -------------------- ---------- --------------------
12 59F7 9-1512 selected lines.
SQL >
SY.
-
loads the hyperlink in picture of a xml file
Hi all
I'm completely new to Flex and got stuck with this problem:
I would like to put a hyperlink in a picture, both are loaded from an external xml file
XML looks like this:
< project >
< id > 0 < /ID >
Google project < title > < / title >
Image1.gif < image > < / image >
www.Google.com < URL > < url >
< date > 01/06/2008 < / date >
< description > a few description < / description >
< / project >The url must therefore be put into image 1
Hope someone can help me...
Thanks in advance!
the example I posted above shows you how to pass XML information to a flex application,
Here's an example of how make images act as hyperlinks
http://www.mattlefevre.com/viewExample.php?tut=Flex&proj=image%20Hyperlink
in your case, you'll want to pass the data.url value to the newBrowserWindow function
-
Need to find all the possible child records with SQL
Hello - I am trying to find a way to solve the following with a sql statement:
I have a table with columns, and the following values:
So basically, 1 is the master parent and I need to bring all ranks, because they are all ultimately originated due to 1. How to write sql code to return all possible levels associated with parent_id = 1?Trans_Id Parent_Trans_id 1 null 2 1 3 2 4 3
I hope I'm communicate that effectively do this, but please let me know if it needs to be clarified.
Any help is greatly appreciated...
Thank you
ChristineHi, Christine.
I think you want to CONNECT BY, something like this:
SELECT * FROM a START WITH trans_id = 1 CONNECT BY parent_trans_id = PRIOR trans_id ;
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002}
You will find the answers better faster if you always provide this information whenever you post a question. -
Rebuild the parent/child (connect by prior and where clause)
Hi guys, you have a quick question for you - code as follows:
with t1 as)
Select 1 id, 'Name1' some_name, null, 'Y' parent_id of double some_flag
Union select 2 id, 'Name2', 1 parent_id, 'Y' some_flag of the double
Union select 3 id, "Name3", 2 parent_id, "n" of the double some_flag
Union select id 4, 'Name4.1', 3 parent_id, 'Y' some_flag of the double
Union select id 5, 'Name4.2', 3 parent_id, 'Y' some_flag of the double
Union select id 6, 'Name4.3', 3 parent_id, 'Y' some_flag of the double
Union select id 7, "Name5", 6 parent_id, 'Y' some_flag of the double
)
SELECT id, the_name, parent_id, null new_parent_id
de)
SELECT id, lpad (' ', (level 1) * 3) | some_name the_name, parent_id
from t1
where some_flag = 'Y '.
Start with id = 1
connect by parent_id = prior id
brothers and sisters of order by some_name
)
Output:
ID, THE_NAME, PARENT_ID, NEW_PARENT_ID
1, Name1,
2, name2, 1,.
4, Name4.1,3,
5, Name4.2,3.
6, Name4.3, 3,.
7, name5, 6,.
As you can see, id = 3 is not displayed (because of where some_flag = 'Y'), but parent_id for id in (4,5,6) shows 3.
-Only by using SQL - display 'current parent in valid results' as new_parent_id?
In this example that would be showing new_parent_id = 2 for the id in (4,5,6)
Currently on Oracle 11 g 1 material.
Similar theme (manipulate path), but seems to work with the brothers and SŒURS of ORDER BY.
SELECT id, the_name, parent_id, some_flag, new_parent_id
FROM (SELECT id, lpad (' ', (LEVEL - 1) * 3): some_name the_name,)
some_flag, parent_id,
REGEXP_SUBSTR)
REGEXP_SUBSTR)
SYS_CONNECT_BY_PATH)
DECODE (some_flag, 'Y', id), ' / ').
'[0-9]+[/]+[0-9]+$'),
(0-9] +') new_parent_id
FROM t1
WHERE some_flag = 'Y '.
START WITH id = 1
CONNECT BY PRIOR ID = parent_id
ORDER OF brothers and SŒURS some_name);
-
the fastest way to load an XML file
What is the fastest way to generate an xsd-based oracle table and then load data from a file that conforms to the xml document in the xsd.
I would do something like this:
SQL > insert into tmp_xml
2 values)
3 xmltype (bfilename('TEST_DIR','test.xml'), nls_charset_id ('AL32UTF8'))
4 );
1 row inserted
SQL >
SQL > select x1.col_a, x1.col_b, x1.col_c, x2.*
tmp_xml 2 t
3, xmltable)
4 "/ parent/Child1.
5 passage t.object_value
path of 6 columns col_a varchar2 (10) '@ColumnA '.
7 road of varchar2 (10) col_b '@ColumnB '.
8 road of varchar2 (10) col_c '@ColumnC '.
9, child2 xmltype path "Child2".
(10) x 1
11, xmltable)
12 ' / Child2'
13 passage x1.child2
path of 14 columns col_d varchar2 (10) 'ColonneD '.
15 road of varchar2 (10) col_e "child3/column.
16, road of varchar2 (10) col_f "child3/ColumnF.
17 road of varchar2 (10) col_g "child3/column".
18 road of varchar2 (10) col_h "child3/ColumnH.
19 road to varchar2 (10) col_i 'ColumnI.
(20) x 2
21;
COL_A, COL_B, COL_C COL_D COL_E COL_F COL_G COL_H COL_I
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
CAF ClientID ClientName 20130121 D 20752,19 AUD
FCA ClientID ClientName M 20130121 235.39 bla Blahdeblah AUD
(you can adjust data types as needed)
-
ASP / PHP pages: how to get the streaming of information from an XML file?
Hi all
I use Adobe Flash Media Streaming Server 3.5 but I can't find any file output (an XML fx) that I can pull info from and use it on my site via a script PHP or ASP. It might be nice - website - to retrieve the info like 'attending of online users', ' running / streaming State "(online or offline) and other relevant information on streaming, so I on the site Web can I view how many who are online when a webtv event is streaming.
I see the news when I connect to the web admin for FMS, but I need a solution that can work with ASP or PHP.
Simply, I can't find any file / address for this type or exit out of FMS - can you help me?
Thank you
Kind regards
Jens
What is rtmp url to which you are connected? RTMP://servername/live/Server1 or just rtmp://serverName/live?
-
parents and children of the same table records
I want to create a query that is a union such that 2nd resultset is based on the game of results 1. I have a table that has parent and child records in the same table.
Table: EVENTS
EVENT_ID
PARENT_EVENT_ID
CREATED_DATE
(other columns)
If PARENT_EVENT_ID is null, then this is a parent record, otherwise it is a book of the child. I want to select all parent records then union them with all the related child records... something like this:
Select * from EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null - all parents
Union
Select * event where PARENT_EVENT_ID in (select EVENT_ID of EVENTS where CREATED_DATE < sysdate - 90 and PARENT_EVENT_ID is null)-include all children selected from the top parent
It works but it of kind of ugly, I want to avoid using the subselect in the 2nd because it is a repeat of the 1st statement, is there a way to alias the first statement and only refer to him in the 2nd query?Hello
CONNECTION is very similar to a UNION on the same table. How is this:
SELECT * FROM events WHERE created_date < SYSDATE - 90 START WITH parent_event_id IS NULL CONNECT BY parent_event_id = PRIOR event_id AND LEVEL <= 2 -- Maybe ;
?
To answer your question: Yes, you can still keep the result set of a query and the Treaty as if it were a table or vew, like this:
WITH roots AS ( SELECT * FROM events WHERE created_date < SYSDATE - 90 AND parent_event_id IS NULL ) SELECT * FROM roots -- UNION ALL -- SELECT * FROM events WHERE created_date < SYSDATE - 90 AND parent_event_id IN ( SELECT event_id FROM roots ) ;
It's always a bit ugly, however. I would use CONNECT BY or from Oracle 11.2, a recursive WITH clause (which is explicitly a UNION), or, in any version, a self-join, like this:
SELECT c.* FROM events c LEFT OUTER JOIN events p ON p.event_id = c.parent_event_id WHERE p.parent_event_id IS NULL ;
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Report where the queriy above (the one you decide to use) is producingthe bad results and explain, using specific examples, how you get the right results from these data in these places.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
Find the child's location in the coordinate space of the parent
I created a map of the counties of Montana. Each county is an MC inside separate the largest parent movie clip (allcnt_mc).
When the user clicks on a County, I would like to focus this country on the scene and the zoom to its measurement.
The hard part has said the parent (allcnt_mc) where the tween to. Given that each individual County is a child of the parent, they have their own coordinate space with reference to the parent.
Is there a way I can query the location (x, y) of a child in the coordinate space of the parent? With this issue, I could calculate the distanct between the point of current regulation of the parent and the child, indicating the distance that the parent will have to move to focus on the scene. I tried to use localToGlobal but could not understand how to use it.
//calculate the stage's center var stagecentx:Number=stage.width/2 var stagecenty:Number=stage.height/2 function tweento(e:MouseEvent):void{ // the first two variables are referncing the county that was most recently clicked on var calledx:Number=allcnt_mc[xmlData.row.NAME[e.currentTarget.ivar]].x; var calledy:Number=allcnt_mc[xmlData.row.NAME[e.currentTarget.ivar]].y; // these variables represent the current location of the stage var allcntx:Number=allcnt_mc.x; var allcnty:Number=allcnt_mc.y; // I'd like to then tween the allcnt_mc to the location of (calledx,calledy) // but in the coordinate space of allcnt_mc
var pt:Point = new Point (parent.child.x, parent.child.y);
PT = parent.localToGlobal (PT);
PT now has the parent.child coordinates in space of the parent coord.
-
Is it possible to fix this parent/child check in a single UPDATE statement?
I can find a not-very-effective solution to the problem after using PL/SQL. However, I am sure that there must be an easier way, using a SQL UPDATE. I was wondering if someone could help me please?
I have a simple table containing 7 rows. Each record is a "parent" or "child". The name is irrelevant. A child is bound to his registration parent via the parent_id. The problem is with the COUNTRY column. All children records COUNTRY values are correct. I need to ensure that all parents have the same value of COUNTRY as do their child records.
- ID = 1 shows an example of a COUNTRY that is missing. It should be filled with the value of the COUNTRY of its children files (ID = 2 and 3), which is "EN".
- ID = 4 shows an example where the parent COUNTRY record is incorrect as "US". It must be filled with registration of her child (ID = 5) COUNTRY of "FROM".
- Some parent lines are properly filled for example ID = 6
- There will never be a situation where a parent record has child records with different countries. The child records will always show the COUNTRY. If several records of the child the COUNTRY will be the same.
Is it possible in block update entire table based on the 4 guidelines above?
-- create table create table attendees( id number, attendee_type varchar2(6), name varchar2(12), country varchar2(2), parent_id number);
-- populate table insert into attendees(id, attendee_type, name) values(1, 'parent', 'John Doe'); insert into attendees(id, attendee_type, name, country, parent_id) values(2, 'child', 'James Doe', 'FR', 1); insert into attendees(id, attendee_type, name, country, parent_id) values(3, 'child', 'Sarah Doe', 'FR', 1); insert into attendees(id, attendee_type, name, country) values(4, 'parent', 'Paul Black', 'US'); insert into attendees(id, attendee_type, name, country, parent_id) values(5, 'child', 'Sam Black', 'DE', 4); insert into attendees(id, attendee_type, name, country) values(6, 'parent', 'Alan White', 'GB'); insert into attendees(id, attendee_type, name, country, parent_id) values(7, 'child', 'Louise White', 'GB', 6);
Hello
Something like:
MERGE INTO presence t1
USING (SELECT distinct id, country, country prior child_country)
Participants
WHERE parent_id is null and before the country is not null
CONNECT BY id = parent_id PRIOR
) t2
WE (t1.id = t2.id)
WHEN MATCHED THEN UPDATE SET t1.country = t2.child_country;
-
Parent - child relationship constraint Unique 5.0 apex oracle
Oky so I will try to avoid duplicate values get inserted in the parent-child node.
So basically when there's a node parent (Mobile) I can't create same node with the same name.
Even for the child node, if there is a child node name there may be another named A.
Structure:
Mobile (parent) /Android (Child) /KitKat (subchild) (allowed)
Mobile/apple/ios(Now allowed Same Parent name)
Win7/Windows/win7(not allowed same child)
So a big child and the parent must be unique at any time.
create an index of single "TEST_UK" on tablename (parent_id, upper (child_name));
see this too for a case-insensitive unique constraint
Maybe you are looking for
-
Launch Firefox on startup with Windows 10
How can I make Firefox will automatically start up when I turn on my computer? At the moment it takes forever to start and I would like to go there as soon as I turn on the machine. I use Windows 10. Thanks in advance.
-
I get not responding is not at all new emails
Whenever I get new e-mail messages Thunderbird reports that he "does not..." After a minute or two downloads the email and I can read it, but I always have to wait at least a minute before the program normally responds... I downloaded another copy of
-
Updated KB2633870 and KB2600217 do not settle
High priority update KB2633870 and KB2600217 software update optionally fail during installation without error code - just failed "not installed".
-
Hello. Anyone know how to copy the contents of a hard drive of 80 GB MK8026GAX Toshiba HDD2191 d ZK01 T to a computer? This record came from a laptop Dell Insipiron PP12L defective 6000. The HARD drive has a 44 pins connector flat male edge. I can't
-
movie maker is being in 64% of su codificación y no me graba el disco
Hola mira tengo a proyecto hecho en movie maker pelicula para there grabarlo manda me a dvd maker, pero cuando doy al cuadro grabar begins codificación del disco y is being in 64% no one self that eso debe are no antes hacias lo mismo y no habia any