Hierarchial query output as xml
Pls find below sample table script and desired output format.XML output should maintain the hierarchy info which is the requirement.Also is it possible to do in single sql.
Thanks.
CREATE TABLE MAIN
ID NUMBER,
NAME VARCHAR2(20 BYTE)
INSERT INTO MAIN ( ID, NAME ) VALUES (
1, 'OS');
INSERT INTO MAIN ( ID, NAME ) VALUES (
2, 'Windows');
INSERT INTO MAIN ( ID, NAME ) VALUES (
3, 'DOS');
INSERT INTO MAIN ( ID, NAME ) VALUES (
4, '1.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
5, '1.1.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
7, '1.1.1.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
8, '1.2');
INSERT INTO MAIN ( ID, NAME ) VALUES (
9, '2.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
10, '2.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
11, '2.2');
INSERT INTO MAIN ( ID, NAME ) VALUES (
12, '2.2.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
13, '2.2.2');
COMMIT;
CREATE TABLE RELA
REL_ID NUMBER,
ID NUMBER,
PARENT_REL_ID NUMBER
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
1, 1, NULL);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
2, 2, 1);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
3, 4, 2);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
4, 5, 3);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
5, 7, 4);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
6, 8, 4);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
7, 9, 2);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
8, 10, 7);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
12, 7, 11);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
14, 9, 9);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
15, 10, 14);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
9, 3, 1);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
10, 4, 9);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
11, 5, 10);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
16, 11, 14);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
13, 8, 10);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
17, 12, 16);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
18, 13, 16);
COMMIT;
Sample Query
select rel_id,level,lpad(' ',5*level)||name,
xmlelement("rel_id", XMLAttributes(name as "name",rel_id as "rel_id")) as val
from main , rela
where main.id=rela.id
start with parent_rel_id is null
connect by prior rel_id=parent_rel_id;
Required xml output
Required xml output
<1 name="OS" >
<2 name="Windows">
<3 name="1.x" 3>
<4 name="1.1.x">
<5 name="1.1.1.1"></5>
<6 name="1.2"></6>
</4>
</3>
<7 name="2.x" >
<8 name="2.1" ></8>
</7>
</2>
<9 name="DOS" >
<14 name="2.x" >
<15 name="2.1" ></15>
<16 name="2.2">
<17 name="2.2.1" ></17>
<18 name="2.2.2" ></18>
</16>
</14>
<10 name="1.x" >
<11 name="1.1.x" >
<12 name="1.1.1.1" ></12>
</11>
<13 name="1.2" >
</13>
</10>
</9>
<1>
Edited by: ravit on Sep 18, 2009 4:47 PM
Edited by: ravit on Sep 19, 2009 9:53 AM
Numbers (or names that start with numbers) are generally not allowed as tag names:
SQL> select xmltype('<1></1>') xml from dual
select xmltype('<1></1>') xml from dual
Error at line 1
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00231: invalid character 49 ('1') found in a Name or Nmtoken
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 310
ORA-06512: at line 1So what you can do is e.g.:
SQL> set echo on
SQL> set pages 5000
SQL> select trim (column_value) xml
from xmltable ('.' passing dbms_xmlgen.getxmltype (dbms_xmlgen.
newcontextfromhierarchy (
'select level, xmlelement (evalname ''r'' || rel_id, xmlattributes(name "name")) name
from main, rela
where main.id = rela.id
start with parent_rel_id is null
connect by prior rel_id = parent_rel_id'
XML
<?xml version="1.0"?>
<r1 name="OS">
<r2 name="Windows">
<r3 name="1.x">
<r4 name="1.1.x">
<r5 name="1.1.1.1"/>
<r6 name="1.2"/>
</r4>
</r3>
<r7 name="2.x">
<r8 name="2.1"/>
</r7>
</r2>
<r9 name="DOS">
<r10 name="1.x">
<r11 name="1.1.x">
<r12 name="1.1.1.1"/>
</r11>
<r13 name="1.2"/>
</r10>
<r14 name="2.x">
<r15 name="2.1"/>
<r16 name="2.2">
<r17 name="2.2.1"/>
<r18 name="2.2.2"/>
</r16>
</r14>
</r9>
</r1>
1 row selected.
Similar Messages
-
ABAP Query output to XML file using Business connector
Hi All,
I would request your help on to know, how can I read the output of ABAP query executed in SAP system via Business connector and then generate a XML file.
Also the existing business connector system, generates the XML file in encoding iso-8859-1. Where as customer wants the output XML file in encoding windows-1252.
Please help with your valuable ideas.
Thanks,Hello,
possible solution:
1. create a remote function module (FM) in SAP which returns your needed data
2. create outbound map in BC for this FM
3. call this FM from BC in a flow
3. extract the result to XML (e.g. with service recordToDocument)
CSY -
Getting Hierarchial Query as XML (and maitaining the relationship)
Pls find below sample table script and desired output format.XML output should maintain the hierarchy info which is the requirement.Also is it possible to do in single sql.
Thanks.
CREATE TABLE MAIN
ID NUMBER,
NAME VARCHAR2(20 BYTE)
INSERT INTO MAIN ( ID, NAME ) VALUES (
1, 'OS');
INSERT INTO MAIN ( ID, NAME ) VALUES (
2, 'Windows');
INSERT INTO MAIN ( ID, NAME ) VALUES (
3, 'DOS');
INSERT INTO MAIN ( ID, NAME ) VALUES (
4, '1.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
5, '1.1.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
7, '1.1.1.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
8, '1.2');
INSERT INTO MAIN ( ID, NAME ) VALUES (
9, '2.x');
INSERT INTO MAIN ( ID, NAME ) VALUES (
10, '2.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
11, '2.2');
INSERT INTO MAIN ( ID, NAME ) VALUES (
12, '2.2.1');
INSERT INTO MAIN ( ID, NAME ) VALUES (
13, '2.2.2');
COMMIT;
CREATE TABLE RELA
REL_ID NUMBER,
ID NUMBER,
PARENT_REL_ID NUMBER
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
1, 1, NULL);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
2, 2, 1);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
3, 4, 2);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
4, 5, 3);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
5, 7, 4);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
6, 8, 4);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
7, 9, 2);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
8, 10, 7);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
12, 7, 11);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
14, 9, 9);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
15, 10, 14);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
9, 3, 1);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
10, 4, 9);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
11, 5, 10);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
16, 11, 14);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
13, 8, 10);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
17, 12, 16);
INSERT INTO RELA ( REL_ID, ID, PARENT_REL_ID ) VALUES (
18, 13, 16);
COMMIT;
Sample Query
select rel_id,level,lpad(' ',5*level)||name,
xmlelement("rel_id", XMLAttributes(name as "name",rel_id as "rel_id")) as val
from main , rela
where main.id=rela.id
start with parent_rel_id is null
connect by prior rel_id=parent_rel_id;
Required xml output
<rel_id name="OS" rel_id="1">
<rel_id name="Windows" rel_id="2">
<rel_id name="1.x" rel_id="3">
<rel_id name="1.1.x" rel_id="4">
<rel_id name="1.1.1.1" rel_id="5"></rel_id>
<rel_id name="1.2" rel_id="6"></rel_id>
</rel_id>
</rel_id>
<rel_id name="2.x" rel_id="7">
<rel_id name="2.1" rel_id="8"></rel_id>
</rel_id>
</rel_id>
<rel_id name="DOS" rel_id="9">
<rel_id name="2.x" rel_id="14">
<rel_id name="2.1" rel_id="15"></rel_id>
<rel_id name="2.2" rel_id="16">
<rel_id name="2.2.1" rel_id="17"></rel_id>
<rel_id name="2.2.2" rel_id="18"></rel_id>
</rel_id>
</rel_id>
<rel_id name="1.x" rel_id="10">
<rel_id name="1.1.x" rel_id="11">
<rel_id name="1.1.1.1" rel_id="12"></rel_id>
</rel_id>
<rel_id name="1.2" rel_id="13">
</rel_id>
</rel_id>
</rel_id>
</rel_id>will this work?
select xmlelement("rel_id",
(select dbms_xmlgen.getxmltype
(dbms_xmlgen.newcontextfromhierarchy
('select level,
xmlelement("rel_id",
xmlattributes(a.name as "name",
b.rel_id as "rel_id")
from rela b,
main a
where b.id = a.id
start with parent_rel_id is null
connect by prior rel_id=parent_rel_id'))
from dual)) xmldoc
from dual
XMLDOC
<rel_id><rel_id name="OS" rel_id="1">
<rel_id name="Windows" rel_id="2">
<rel_id name="1.x" rel_id="3">
<rel_id name="1.1.x" rel_id="4">
<rel_id name="1.1.1.1" rel_id="5"/>
<rel_id name="1.2" rel_id="6"/>
</rel_id>
</rel_id>
<rel_id name="2.x" rel_id="7">
<rel_id name="2.1" rel_id="8"/>
</rel_id>
</rel_id>
<rel_id name="DOS" rel_id="9">
<rel_id name="1.x" rel_id="10">
<rel_id name="1.1.x" rel_id="11">
<rel_id name="1.1.1.1" rel_id="12"/>
</rel_id>
<rel_id name="1.2" rel_id="13"/>
</rel_id>
<rel_id name="2.x" rel_id="14">
<rel_id name="2.1" rel_id="15"/>
<rel_id name="2.2" rel_id="16">
<rel_id name="2.2.1" rel_id="17"/>
<rel_id name="2.2.2" rel_id="18"/>
</rel_id>
</rel_id>
</rel_id>
</rel_id>
</rel_id>
1 row selected. -
Output query result in XML format
folks:
could anybody provide more information
about how to generate query result in
xml format? looks like DBXML is for demo only
and i have heard that PLSQL XML parser is the way to go; so far i have not found
a sample yet on how to actually
do the XML generation; if you know more
about it, please let me know; thanks in
advance.
BillHere are some sample apps that might interest you:
[list]
[*][url [URL=http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The]http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The XML Flight Finder
[*][url [URL=http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B]http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B with XML
[list]
Enjoy,
-rh -
Report VS Excel output using XML Publisher tool (DBMS_XMLGEN)
Hi All,
Currently I am working on report generation in MRP module with Excel output using XML Publisher tool.
XML tool works based on query.
I have developed PLSQL block by using DBMS_XMLGEN – database package, to generate XML output of query.
My question is how we can put generated xml on above PLSQL block into OUT file (APPS).
Because DBMS_OUTPUT.PUT_LINE( ) has limitation, it allow 255 character string only.
But I do not know, Is FND_FILE.PUT_LINE (FND_FILE.OUTPUT,’’) allow for large data?
If it does not allow what will be the other solution in oracle application to resolve above problem.
Let me know any queries regarding to this problem.
Thanks and Regards,
Sai Krishna @cavaya.comHi Prakash,
Thanks for the reply. We did apply the one-off patch and got rid of the problem of not viewing 'Excel' output using XMLP.
Now we are looking at a different perspective:
Basically our client is looking for the following:
1. Mathematical functions in the resulting XLS (like SUM, AVG etc..) ouput
2. Use of macros if possible.
And to do this i am looking out for a sample template that gives me output in excel format I have a TAR with Oracle for this purpose, but the TAR has so far been unsuccessful in providing us with any material in the direction.
Our client remembers seeing this as a demo at the Oracle Conference this yr at San Fransisco, but does not have a sample to provide us. We are looking for such a sample.
Thx,
Nitin -
XML Publisher data engine vs. switching output to XML in the Con.Program.
What is the difference between setting up templates using the data engine described in the 5.6 user's guide and creating a customer report and setting its output to XML?
Is it a matter of you being able to totally create your own XML and add atrributes to tags and such? Is this the only way to get data output from Oracle into an XML file? It's been a while, but i recall creating XML output on the fly with .Net pretty easily via an ASPX page.
Seems like alot of work to achieve this? Am I missing something?
If I wanted to have a JSP page where a user could use a form to query the database via IE, are these the API's i need to use for the returned data to come back as XML?
Thanks,
JeremyYou should try posting your query in XML Publisher forum, which is now BI Publisher.
-
How to generate PDF from XML output without XML publisher
Hi,
I am facing a problem while splitting the rdf generated XML output.
Problem Description:
I have a oracle invoice report which runs once every day (scheduled program). This report fetches me the invoices generated on that day and needs to be Mailed / Faxed to the customers.
So i developed the report in such a way that it generates the output order by customers...since the output generated will be as one .out file in APPLCSF/out directory...the .out file needs to be splitted by customers, for which i have written a cursor which takes the data of the main query and submits that many requests as many as customers are there.....There is a possibility of having 1000 customers per day also. If that is the case then my main program will fire that many requests.
Is there a different approach......any inputs are highly appreciated.
Also, i am generating the output in XML format. Is there a way from which i can directly generate a PDF from that XML output rather using any other tool.
Thanks & Regards,
Lakshmi Kalyan Vara Prasad.Hi,
with Reports Bursting and the defined "distributions" it's possible to have one report splittet to several parts with different receipients. Have a look at http://download-uk.oracle.com/docs/cd/B14504_01/dl/bi/B13673_01/pbr_dist.htm.
With xsl-fo it's possible to create pdf out of xml ... that's what xml publisher is doing.
Regards
Rainer -
Hi All..
I have a hierarchy query with description as below
SQL> desc manager_entity;
Name Null? Type
MANAGER_ENTITY_ID NOT NULL NUMBER
MANAGER_ENTITY_TYPE_ID NOT NULL NUMBER
MANAGER_ENTITY_PARENT_ID NUMBER
CREATE_USER NOT NULL VARCHAR2(50)
CREATE_DATETIME NOT NULL DATE
LAST_UPDATE_USER NOT NULL VARCHAR2(50)
LAST_UPDATE_DATETIME NOT NULL DATE
MANAGER_ENTITY_LINK_ID NOT NULL NUMBERI got the correct relation between the parent and child using the below query
select me.manager_entity_id
, me.manager_entity_type_id
, me.manager_entity_parent_id
, me.manager_entity_link_id
, level
from manager_entity me
start with me.manager_entity_id=:p_id
connect by prior me.manager_entity_id=me.manager_entity_parent_idWhen I try to join this table with other 3 tables I’m unable to retrieve data. Description of the other 3 tables
SQL> desc manager_product;
Name Null? Type
MANAGER_PRODUCT_ID NOT NULL NUMBER
MANAGER_PRODUCT_NAME NOT NULL VARCHAR2(50)
MANAGER_ROOF_ID NOT NULL NUMBER
ACT_STRATEGY VARCHAR2(50)
ACT_SUB_STRATEGY VARCHAR2(50)
ACT_DATE_ENTERED DATE
ACT_INCEPTION_DATE DATE
ACT_PEER_GROUP VARCHAR2(50)
BACK_OFFICE_RISK_ID NUMBER
AREA_ID NUMBER
ACT_CREATE_DATE DATE
PROCESS_STOP_DATE DATE
TARGET_COMPLETION_DATE DATE
REVISIT_DATE DATE
CREATE_USER VARCHAR2(50)
CREATE_DATETIME DATE
LAST_UPDATE_USER VARCHAR2(50)
LAST_UPDATE_DATETIME DATE
SQL> desc manager_roof;
Name Null? Type
MANAGER_ROOF_ID NOT NULL NUMBER
MANAGER_ROOF_NAME NOT NULL VARCHAR2(50)
ROOF_COMPANY_ID NOT NULL NUMBER
CREATE_USER VARCHAR2(50)
CREATE_DATETIME DATE
LAST_UPDATE_USER VARCHAR2(50)
LAST_UPDATE_DATETIME DATE
SQL> desc investment_vehicle;
Name Null? Type
INVESTMENT_VEHICLE_ID NOT NULL NUMBER
INVESTMENT_VEHICLE_NAME NOT NULL VARCHAR2(255)
INVESTMENT_VEHICLE_ARRT_NAME VARCHAR2(255)
INVESTIER_SYSID NUMBER
INVESTIER_ID VARCHAR2(100)
MANAGER_PRODUCT_ID NUMBER
TRADING_STRUCTURE_TYPE_ID NUMBER
LEGAL_DESIGNATION_ID NUMBER
ADDITIONAL_INVEST_FORM_TYPE_ID NUMBER
INVESTMENT_VEH_CLASS_TYPE_ID NUMBER
ERISA_PLAN_ASSET_CATEGORY_ID NUMBER
SIDE_LETTER_FLAG CHAR(1)
INCEPTION_DATE DATE
ALLOW_ERISA_FLAG CHAR(1)
ALLOW_PLAN_ASSET_FLAG CHAR(1)
ALLOW_US_TAXABLE_INVESTOR_FLAG CHAR(1)
ALLOW_OFFSHORE_INVESTOR_FLAG CHAR(1)
SUB_DOC_DEADLINE NUMBER
WIRE_DEADLINE NUMBER
DOMICILE_COUNTRY_ID NUMBER
CREATE_USER VARCHAR2(50)
CREATE_DATETIME DATE
LAST_UPDATE_USER VARCHAR2(50)
LAST_UPDATE_DATETIME DATE
PERTRAC_DATA_VENDOR_ID VARCHAR2(255)
PERTRAC_DATA_VENDOR_NAME VARCHAR2(255)
FTS_NAME VARCHAR2(255)
MATLAB_MANAGER_NAME VARCHAR2(255)
ACT_CO_FUND_NAME VARCHAR2(255)
ACT_INVESTMENT_VEHICLE_NAME VARCHAR2(255)
SIDE_POCKET_PCT NUMBER
MAX_ILLIQUID_PCT NUMBER
CONTRIBUTION_OPENING_ID NUMBER
MANAGEMENT_FEE_PCT NUMBER
INCENTIVE_FEE_PCT NUMBER
SIDE_POCKET_NOTE VARCHAR2(4000)
FTS_ID NUMBERI was trying to join the other 3 tables with the main query as below..
select me.manager_entity_id
, me.manager_entity_type_id
, me.manager_entity_parent_id
, me.manager_entity_link_id
, level
from manager_entity me
, manager_roof mr
, manager_product mp
, investment_vehicle iv
where me.manager_entity_link_id= mr.manager_roof_id
and mr.manager_roof_id= mp.manager_roof_id
and mp.manager_product_id= iv.manager_product_id
start with me.manager_entity_id=:p_id
connect by prior me.manager_entity_id=me.manager_entity_parent_idHere manager_entity_link_id of manager_entity table represents(or has) the primary key of all the other 3 table..like
Enter value for p_id: 1
old 7: start with me.manager_entity_id=&p_id
new 7: start with me.manager_entity_id=1
MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID
MANAGER_ENTITY_LINK_ID LEVEL
1 1008
14793 1
263 1009 1
19695 2
803 1010 263
7031783 3
MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID
MANAGER_ENTITY_LINK_ID LEVEL
804 1010 263
7031782 3
805 1010 263
7031781 3The above is the output for the hierarchy query
Here the MANAGER_ENTITY_LINK_ID has values (14793, 19695, 7031783 , 7031782 , 7031781)
Where 14793 is the manager_roof_id in manager_roof_table
19695 is the manager_product_id in the manager_product table
7031783 , 7031782 , 7031781 are the investment_vehicle_id’s in the investment_vehicle table…
In the output I need to retrieve manager_roof_name, manager_product_name, investment_vehicle_name..
Thanks in advance
HTH
Edited by: user10280715 on Dec 3, 2008 11:55 AMThe reason result show as no rows selected is your first insert. If fails since column list has 3 columns while values list has 4 values. You probably missed "ORA-00913: too many values" error:
SQL> drop table manager_entity
2 /
Table dropped.
SQL> create table manager_entity(manager_entity_id number,manager_entity_type_id number,manager_entity_parent_id number,manager_entity_link_id number)
2 /
Table created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_link_id)
2 values(1,1008,null,14793)
3 /
insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_link_id)
ERROR at line 1:
ORA-00913: too many values
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(263, 1009, 1, 19695)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(803, 1010, 263, 7031783)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(804, 1010, 263, 7031782)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(805, 1010, 263, 7031781)
3 /
1 row created.
SQL> drop table manager_roof
2 /
Table dropped.
SQL> create table manager_roof(manager_roof_id number,manager_roof_name varchar2(20))
2 /
Table created.
SQL> insert into manager_roof(manager_roof_id,manager_roof_name)
2 values(14793,'roof')
3 /
1 row created.
SQL> drop table manager_product
2 /
Table dropped.
SQL> create table manager_product(manager_product_id number,manager_product_name varchar2(20),manager_roof_id number)
2 /
Table created.
SQL> Insert into manager_product(manager_product_id,manager_product_name,manager_roof_id)
2 Values(19695,'product1', 14793)
3 /
1 row created.
SQL> drop table investment_vehicle
2 /
Table dropped.
SQL> create table investment_vehicle(investment_vehicle_id number,manager_product_id number,investment_vehicle_name varchar2(20))
2 /
Table created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031781,19695,'inv1')
3 /
1 row created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031782,19695,'inv3')
3 /
1 row created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031783,19695,'inv3')
3 /
1 row created.
SQL> COMMIT
2 /
Commit complete.
SQL>
SQL> select me.manager_entity_id
2 , me.manager_entity_type_id
3 , me.manager_entity_parent_id
4 , me.manager_entity_link_id
5 , level
6 from manager_entity me
7 start with me.manager_entity_id=&p_id
8 connect by prior me.manager_entity_id=me.manager_entity_parent_id
9
SQL> /
Enter value for p_id: 1
old 7: start with me.manager_entity_id=&p_id
new 7: start with me.manager_entity_id=1
no rows selectedAs soon as you fix the error:
SQL> drop table manager_entity
2 /
Table dropped.
SQL> create table manager_entity(manager_entity_id number,manager_entity_type_id number,manager_entity_parent_id number,manager_entity_link_id number)
2 /
Table created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(1,1008,null,14793)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(263, 1009, 1, 19695)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(803, 1010, 263, 7031783)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(804, 1010, 263, 7031782)
3 /
1 row created.
SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
2 values(805, 1010, 263, 7031781)
3 /
1 row created.
SQL> drop table manager_roof
2 /
Table dropped.
SQL> create table manager_roof(manager_roof_id number,manager_roof_name varchar2(20))
2 /
Table created.
SQL> insert into manager_roof(manager_roof_id,manager_roof_name)
2 values(14793,'roof')
3 /
1 row created.
SQL> drop table manager_product
2 /
Table dropped.
SQL> create table manager_product(manager_product_id number,manager_product_name varchar2(20),manager_roof_id number)
2 /
Table created.
SQL> Insert into manager_product(manager_product_id,manager_product_name,manager_roof_id)
2 Values(19695,'product1', 14793)
3 /
1 row created.
SQL> drop table investment_vehicle
2 /
Table dropped.
SQL> create table investment_vehicle(investment_vehicle_id number,manager_product_id number,investment_vehicle_name varchar2(20))
2 /
Table created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031781,19695,'inv1')
3 /
1 row created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031782,19695,'inv3')
3 /
1 row created.
SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
2 Values(7031783,19695,'inv3')
3 /
1 row created.
SQL> COMMIT
2 /
Commit complete.
SQL>
SQL> select me.manager_entity_id
2 , me.manager_entity_type_id
3 , me.manager_entity_parent_id
4 , me.manager_entity_link_id
5 , level
6 from manager_entity me
7 start with me.manager_entity_id=&p_id
8 connect by prior me.manager_entity_id=me.manager_entity_parent_id
9
SQL> /
Enter value for p_id: 1
old 7: start with me.manager_entity_id=&p_id
new 7: start with me.manager_entity_id=1
MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID MANAGER_ENTITY_LINK_ID LEVEL
1 1008 14793 1
263 1009 1 19695 2
803 1010 263 7031783 3
804 1010 263 7031782 3
805 1010 263 7031781 3
SQL> SY. -
Report output format xml, missing column while open in excel for single row
Dear,
There is a strange case, we have an customize concurrent program to display output in xml format. Now Problem is, if query get single record on the bases of parameter then there is no column heading available in excel. However, if parameter meet more than one record then there is no issue with column heading and reports is working find.
Pls have an idea?Dear Pk,
Here is an example, will show the actual problem. Let explain you, first i have run report by restricting query on single record which output name is "output1", again i run same report by changing where clause so it return multiple row which is "output2". if you past code in text document each one and save it as xml but when you open this file in excel report you will find column heading which rows consist multiple row, however, ouput1 file have no heading columns that's a problem.
1.Oputput1
<?xml version="1.0"?>
<!-- Generated by Oracle Reports version 6.0.8.11.3 -->
<DEPTNO>
<LIST_G_EMPNO>
<G_EMPNO>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
<HIREDATE>17-NOV-81</HIREDATE>
<SAL>5000</SAL>
<DEPTNO>10</DEPTNO>
</G_EMPNO>
</LIST_G_EMPNO>
</DEPTNO>
2.Oputput2
<?xml version="1.0"?>
<!-- Generated by Oracle Reports version 6.0.8.11.3 -->
<T01103240>
<LIST_G_EMPNO>
<G_EMPNO>
<EMPNO>7788</EMPNO>
<ENAME>SCOTT</ENAME>
<HIREDATE>09-DEC-82</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</G_EMPNO>
<G_EMPNO>
<EMPNO>7902</EMPNO>
<ENAME>FORD</ENAME>
<HIREDATE>03-DEC-81</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</G_EMPNO>
</LIST_G_EMPNO>
</T01103240>
Hope you got it. -
Hierarchy Query to get parent nodes?
Hi Everyone,
I want to write a hierarchy query which should give me the path starting from given node to its parents(Grand parents). below is the sample data and the output what i am expecting. and also the output what i am getting right now from my query.
CREATE TABLE RELATION (PARENT VARCHAR2(5),CHILD VARCHAR2(5) PRIMARY KEY);
--Data for the tree which starts from the root 'A'
Insert into RELATION (PARENT, CHILD) Values (NULL,'A');
Insert into RELATION (PARENT, CHILD) Values ('A', 'B');
Insert into RELATION (PARENT, CHILD) Values ('A', 'C');
Insert into RELATION (PARENT, CHILD) Values ('B', 'D');
Insert into RELATION (PARENT, CHILD) Values ('B', 'E');
Insert into RELATION (PARENT, CHILD) Values ('D', 'F');
Insert into RELATION (PARENT, CHILD) Values ('C', 'G');
--Data for the tree which starts from the root 'H'
Insert into RELATION (PARENT, CHILD) Values (NULL,'H');
Insert into RELATION (PARENT, CHILD) Values ('H', 'I');
Insert into RELATION (PARENT, CHILD) Values ('H', 'J');
Expected Output by passing values as 'F' which gives the path from bottom to up.
A<-B<-D<-F
My Query:
SELECT substr(sys_connect_by_path(child,'<-'),3)
FROM relation
WHERE connect_by_isleaf = 1
START WITH child = 'F'
CONNECT BY PRIOR parent = child
ORDER BY child;
Output of my query:
F<-D<-B<-A
I am getting the output in reverse order. i can use the reverse string function to reverse the string but the problem is the node can also contain the values like 'AC' 'BA'.. in future.
Can anyone please help me in getting the correct output.
Thank you in advance.I like ListAgg :D
with RELATION(PARENT,CHILD) as(
select NULL,'A' from dual union all
select 'A', 'B' from dual union all
select 'A', 'C' from dual union all
select 'B', 'D' from dual union all
select 'B', 'E' from dual union all
select 'D', 'F' from dual union all
select 'C', 'G' from dual union all
select NULL,'H' from dual union all
select 'H', 'I' from dual union all
select 'H', 'J' from dual)
SELECT ListAgg(child,'<-')
within group(order by Level desc) as revPath
FROM relation
START WITH child = 'F'
CONNECT BY PRIOR parent = child;
revPath
A<-B<-D<-F -
Hi All,
I have below tables,
Tables
1 Employees Type (Tells About Employees Designation)
2.Employee Details (Tells Employee Details)
3.Employee Relation (Tells Relationship between Employees)
Hierarchy
ARC (SENIOR MANAGER)
SUN (MANAGER)
MOON (TECH LEAD)
LITE (EMPLOYEE)
RAG (TECH LEAD)
BESH (TECH LEAD)
CHESH (EMPLOYEE)
PRASAD (EMPLOYEE)
1 Employees Type Data
Type No||Type Name
1|Employee
2|Tech Lead
3|Manager
4|Senior Manager
2.Employee Details
Emp No||Emp Name|Employee Type
10|ARC|4
20|SUN|3
30|RAG|2
40|PRASAD|1
50|MOON|2
60|LITE|1
70|CHESH|1
80|BESH|2
3. Employee Relation
Relation Number|Emp No|Prnt_Relation Number
1|10|NULL
2|20|1
3|30|1
4|40|1
5|50|2
6|60|2
7|70|3
8|80|3
These are my tables structure,
Now I want Hierarchial Query for below,
Input will be Relation Number,
if I give relation number as input I want to display all immediate childern that are Tech Leads and Employees only (it should ignore if it is having any Managers in the result set)
Ex: -
Input is relation number from Employee Relation Table,
If I give input as *1*
Output Should be,
Relation Number|Employee_id|Employee Name
3|30|Rag
7|70|Besh
8|80|Chesh
If I give input as *2*
Output Should be,
Relation Number|Employee_id|Employee Name
5|50|MOON
6|60|LITE,
If I give input as *4*
Output Should be,
Relation Number|Employee_id|Employee Name
<NO Rows Returned>
Thanks,Hi,
with emp_type as ( select 1 type_id, 'Employee' emp_type from dual
union
select 2 type_id, 'Tech Lead' emp_type from dual
union
select 3 type_id, 'Manager' emp_type from dual
union
select 4 type_id, 'Senior Manager' emp_type from dual),
emp_details as ( select 10 emp_no, 'ARC' fname, 4 type1 from dual
union
select 20 emp_no, 'SUN' fname, 3 type1 from dual
union
select 30 emp_no, 'RAG' fname, 2 type1 from dual
union
select 40 emp_no, 'PRASAD' fname, 1 type1 from dual
union
select 50 emp_no, 'MOON' fname, 2 type1 from dual
union
select 60 emp_no, 'LITE' fname, 1 type1 from dual
union
select 70 emp_no, 'CHESH' fname, 1 type1 from dual
union
select 80 emp_no, 'BESH' fname, 2 type1 from dual),
Emp_Relation as (
select 1 Relation, 10 emp_no1, null parent_Relation from dual
union
select 2 Relation, 20 emp_no1, 1 parent_Relation from dual
union
select 3 Relation, 30 emp_no1, 1 parent_Relation from dual
union
select 4 Relation, 40 emp_no1, 1 parent_Relation from dual
union
select 5 Relation, 50 emp_no1, 2 parent_Relation from dual
union
select 6 Relation, 60 emp_no1, 2 parent_Relation from dual
union
select 7 Relation, 70 emp_no1, 3 parent_Relation from dual
union
select 8 Relation, 80 emp_no1, 8 parent_Relation from dual)
select type_id, emp_type,
emp_no, fname, relation, parent_relation
from EMP_DETAILS, EMP_TYPE, EMP_RELATION
WHERE TYPE_ID = type1
AND EMP_NO = EMP_NO1
AND LEVEL = 2
CONNECT BY PRIOR RELATION = PARENT_RELATION
START WITH RELATION = :P_RELATION
--START WITH PARENT_RELATION IS NULL -- If want to display the complete heirarchy remove comments for this line and remove "and level = 2" and "START WITH RELATION = :P_RELATION"For p_relation = 1
TYPE_ID EMP_TYPE EMP_NO FNAME RELATION PARENT_RELATION
3 Manager 20 SUN 2 1
2 Tech Lead 30 RAG 3 1
1 Employee 40 PRASAD 4 1
3 rows selected.Not sure how do you get the following and it's not clear on what basis.
If I give input as *1*
Output Should be,
Relation Number|Employee_id|Employee Name
3|30|Rag
7|70|Besh
8|80|CheshFor p_relation = 2
TYPE_ID EMP_TYPE EMP_NO FNAME RELATION PARENT_RELATION
2 Tech Lead 50 MOON 5 2
1 Employee 60 LITE 6 2
2 rows selected.For p_relation = 3
TYPE_ID EMP_TYPE EMP_NO FNAME RELATION PARENT_RELATION
1 Employee 70 CHESH 7 3
1 row selected.For p_relation = 4
no rows selected.Hope this helps
Best Regards
Arif Khadas
Edited by: Arif Khadas on Jun 29, 2010 12:47 PM -
Suppress zero rows in the query output.
Dear Experts,
We executed a query. In the output the values are displayed based on a hierarchy on gl account.
But in the output some rows dont have any values i.e 0 value. Still those rows are appearing in the report output.I want to
supress entire row. How to supress the entire row if no value i.e zeros are appearing in the query output.
Regards,
Bhadri M.go to change mode of query
in that set the query properties /go to the query property secreen
in the "Display " tab set the supperssion as "active (all value=0)" and in structure properties select the check box "also use zero suppression for strucure element"
i think it will be help ful
Edited by: Soma Venkateshwarlu on Aug 28, 2009 2:40 PM -
Result Row in the query output
Hi,
If I restrict a characteristic by hierarchy then I cant have the result row displayed. If the hierarchy active is removed then the result row gets displayed. All characteristics are marked to show the result row.
This characteristic is Account Number. If in the query definition I remove the restriction on account numbers and just select hierarchy active and the required hierarchy in the properties then I get the result row in the output. But now it also displays all the unassigned account numbers in a separate node Not Assigned Account Number (s).
I cant even restrict it in the output with hierarchy active selected. When I do select filter value in the output the options Include in Selection and exclude from Selection are grayed out and hence cant select it.
Please advice on this issue
Thank you,
samHi Jaya,
I think you misunderstood my issue.
My problem is not that i do not want to see the field. But instead, i do not want to see only the results row in the query output.
I need to have the results to populate a calculation via sumct formula.
My question is, can sumct be populated if i hide/supress RESULT row ?
Regards,
Maili -
Issue with Saving the Query output data in Excel format
Hi,
Recnetly we had upgraded from 4.6c to ECC 6.0.
In ECc 6.0 environment, when user try to export the query output , we are getting only XML option to save the data.
But user want to save the data in EXcel format, he was able to do that in 4.6C.
pleas eprovide some inputs, on this issue.
Thanks,
Sanketh.I cannot for the life of me imagine, why a link to a post in the 'Business One Forum' where one uses ODBC to transfer query-data to MicroSoft Excel is of relevance to the OPs question, even if the same is not a security issue.
Never mind. [note 40155|https://service.sap.com/sap/support/notes/402155] deals with various symptoms in the ALV-Excel combination as as of release 4.6C. There are various others, mostly in components BC-SRV-ALV and BC-ABA-LI - also: I remember that when we upgraded from 4.5B to 4.7C there was an issue with Excel-templates -> the solution was in the release notes somewhere. So, in addition to SMP you might want to check the release notes and/or upgrade guide for solutions.
And yes, moderators ... this is not a security issue, this should go to ECC-Applications/Upgrade. -
How to regenerate output in XML format after having assigned RTF Template
1. I created a concurrent request to get the output in XML data format
2. Having created RTF File and assigned Data Definition and Template through XML Administartor Responsibility
3. Now I want to make changes in Data Definition XML File, However I need to get the output file in XML data format, However Concurrent Request is not allowing me to get the XML output because Template is already assigned for the output and not able to de-assign template file from concurrent request.
For some reason in XML publisher, the end date for Template is disable, I am not able to update end date for template.
Is there any way to create an output in XML format through concurrent request after Template File is assigned to create an output? I will appreciate your help.This is for people who want to know more in detail. Problem is if you put end date then you have to recreate an entry and then have to go through the same process. However I have found a way to use the same file,
Get the template_id by running the following query
select * from xdo_templates_b
where template_code = 'TEMPLATE_CODE'
Run the following query to update the end_date to some previous date value
update xdo_templates_b
set end_date = to_date('6/9/2011','mm/dd/yyyy')
where template_id = 162
After that when you run request through concurrent request, it will not show the default template assigned to concurrent request. Run the request, output will be created in XML format.
Run the following query to use the template again
update xdo_templates_b
set end_date = null
where template_id = 162
Edited by: user9941374 on Jun 10, 2011 9:20 AM
Maybe you are looking for
-
I have an iPhone 5 that must be just over a year old now. I don't remember exactly when this problem started, but I think it was right after updating to IOS 7. The problem is that with certain searches, such as "chrome" or "calender", the spotlight s
-
I must allow users to use Firefox or Internet explorer while I can easliy contorl the homepage using a GPO for IE I cannot do the same for firefox. I found great information on a way that I can create a config file and then promulgate it to the users
-
Nike Site Still Acting Strange and Trouble With Nano
I did a 5k last night, around 9:30 PM (it's very hot here) and synced up around 10:30 PM. It showed up in my runs, but not in a challenge I am in. I checked this morning and it was there, but showed that I did it at 1:02 AM! I ran this morning and sy
-
Can you make a scrollable table in LiveCycle Designer?
Hi there, The pages I have developed in my eFrom are sometimes not large enough when the user adds several rows to a table. Is it possible to create a table that occupies a fixed area and scrolls when the number of rows exceed this area? Many thanks
-
Having already captured media, i am planning to take notes, export a batch list in .txt format so i can re-order items to configure a paper edit/first cut... can i then re-import the batch list and create an EDL to use to re-connect media, to make th