Group by and table Join
Hi Expert,
I am new for pl/sql I have some question ..
I have table like this
1. table productcost has column productcostID,costID,DeptID,REQUESTCOST,EXPENDITURECOST
2. table COST has column costID , costName,costmajorID,costtypeID
3. table Departments has DeptID,DeptName
4. table CostMajor has costmajorID , costmajorName
i want to query productcost Table where DeptID = somevalue call X and it must contain every productcost has DeptID = X and i want to select costname to show
and i want to group by it by costmajorID in table Cost .... How Can I do that ? Someone please help me ..
My Result Like this (a Table query from table productcost )
table 1
costmajorName1 EXPENDITURECOST REQUESTCOST
costName1 1000000 2000000
costName2 1000000 2000000
table 2
costmajorName2 EXPENDITURECOST REQUESTCOST
costName3 1000000 2000000
costName4 1000000 2000000
table 3
costmajorName3 EXPENDITURECOST REQUESTCOST
costName5 1000000 2000000
costName6 1000000 2000000
ps. I'm not good in english sorry if i made you not understand..
Query for a xml output then but take the below just as a template as I don't have a Database at hand and that's all I can come up with at the moment
You can get more help in the {forum:id=34} forum or wait till Marc shows up ;) or someone else provides a working example
select xmlelement("Table",
xmlelement("Title",
xmlelement("Col_1", costmajor_name),
xmlelement("Col_2", 'expenditure_cost'),
xmlelement("Col_3", 'request_cost')
xmlagg (
xmlelement("Costs",
xmlelement("Col_1", cost_name),
xmlelement("Col_2", expenditure_cost),
xmlelement("Col_3", request_cost)
from (select cm.costmajor_name,c.cost_name,pc.expenditure_cost,pc.request_cost
from productcost pc,
cost c,
costmajor cm
where dept_id = :dept_chosen
and pc.cost_id = c.cost_id
and c.costmajor_id = cm.costmajor_id
group by costmajor_nameRegards
Etbin
Similar Messages
-
Hi,
Is there any limitation regarding an SQL query doing a JOIN of tables from multiple cache groups?
ThanksNo limitations. From a query/DML perspective, cache group tables are just like any other table.
Chris -
Difference between Logicaldatabase and Table Join in Query SQ01
Hello Expert,
To create query, we need to create infoset first. While cration of infoset we have two option
1. Enter Table names and join table
2. Use logical database.
We cant use both option at a time.
I have created a infoset where i have used the logical database PNPCE, Now i have situation where i need to join the two infotype mainly 0021 and 0138. But i cant find any otion wher i can join these two table. If i use these two table in the infoset instead of logical database , i am able to join them using join tool.
When i use logical database, by default infotypes are joined based on the employee number only. Is thetre any option where i can join my two infotype other than employee field???
Regards,
SagarModerator message - Please search before asking - post locked
Rob -
Count(*) with group by and a join
I've the below tables:
Tables:
EMPLOYEE
EMP_ID LNAME FNAME
1000 SLITT JOHN
1001 SLITHER STEVE
1002 JACOB MARLYN
1003 STUFFEY NOSE
1004 SLIPPY MOUTH-----
ACCESS_TYPE
ACCESS_TYPE_ID ACCESS_DESCRIPTION
1 EMPLOYEE
2 EMPLOYEE_ADMIN
3 CONTRACTOR-----
EMPLOYEE_ACCESS
ACCESS_ID ACCESS_TYPE_ID EMP_ID ACCESS_EFF_DATE
1 1 1000 01-JAN-13
2 1 1001 10-FEB-13
3 1 1002 18-FEB-13
4 2 1003 10-OCT-12
5 3 1004 10-MAR-08-----
I'm trying to figure out the count of employees group by their type and whose last name does not start with SL
I've written the query below and I'm getting a 00936 Missing Expression. What am I doing wrong? Thanks
SELECT EA.COUNT(*) , ACCESS_TYPE_ID
FROM EMPLOYEE_ACCESS EA, EMPLOYEE E
WHERE ACCESS_EFF_DATE >= '31-DEC-12' AND E.LNAME NOT LIKE 'SL%'
GROUP BY ACCESS_TYPE_ID;
Edited by: parsar on Mar 25, 2013 3:54 PMthanks for the response.
If I don't use the alias prefix, which table rows will the query count because I've two tables in the from clause.
I've modified the query as below but it doesn't return any data:
SELECT COUNT(*) AS ACCESS_COUNT, ACCESS_TYPE_ID
FROM EMPLOYEE_ACCESS EA , EMPLOYEE E
WHERE EA.EMP_ID=E.EMP_ID AND
ACCESS_EFF_DATE >= TO_DATE('2012-12-31', 'YYYY-MM-DD') AND
E.LNAME NOT LIKE 'SL%'
GROUP BY ACCESS_TYPE_ID;Please let me know which part of the query I screwed up. -
Is it possible to create an index on a view as opposed to a table, when using Oracle Text?
Thanks for the earlier response.
I was also loooking at Oracle Ultra Search. I figured out that Ultr search provides out of the box query application to do free-form text search, parameterized search and so on....
I also read that Oracle Ultra search uses Oracle text as the underlying technology to do the search.
I have a requirement where most of my searches will be on structured data spread across multiple tables. But I also have a requirement to index some static content which resides on the file system.
Is it possible to mix and match query results i.e. first perform a search on the structured data and then perform another search on the static document data and then megre results from both and display back to the user?
Thanks for the help -
i have 2 tables in my report.
table A: group-id, item-id, name, ...
table B: group-id, item-id, detail-id, name, ...
i want to join the 2 table using group-id & item-id.
i tried but the join result is not correct, it looks like only joint on 1 column.
does crystal report support this kind of join?
how can i define the joint condition:
- tableA.group-id = tableB.group-id and tableA.item-id = tableB.item-id
- tableA.group-id = tableB.group-id or tableA.item-id = tableB.item-id
it seems there is no way to specify the "and", "or".
thanks in advanceHello,
Yes CR should allow this unless the DB driver you are using does not support it.
Older DB drivers may not support mutliple joins.
I assume also that you are dragging the field from Table A to Table B and then right clicking on the link and selecting the join type?
What DB are you using and how are you connecting, ODBC, OLE DB, native or ????
What you can do is create the SQL outside of CR and then as a test use a Command and paste in your SQL. If this works then you should be able to do the same in the database expert Linking options.
Thank you
Don
Edited by: Don Williams on Sep 23, 2009 7:26 AM -
3 Table Join with group by and order by clauses
I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
(see below for my work around)
I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
I really appreciate anyone's input. Thanks,
Inder
WORK AROUND:
FIRST STEP:
"create TABLE BIDSUM as
select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
NEXT STEP:
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
THIS ALSO WORKS (no LIKE):
"select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
BUT THIS DOES NOT (alias the DATE arimetic)
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
(see below for my work around)
I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
I really appreciate anyone's input. Thanks,
Inder
WORK AROUND:
FIRST STEP:
"create TABLE BIDSUM as
select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
NEXT STEP:
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
THIS ALSO WORKS (no LIKE):
"select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
BUT THIS DOES NOT (alias the DATE arimetic)
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__'; -
One to Many table join -- concat field per record grouped by id
Post Author: wm5
CA Forum: Formula
Hello,
I am using Crystal Reports XI and have two tables that have a one to many relationship and are joined by an JobID (number).
Below is a sample with relative fields for each table.
job_table: JobID (number), Manager (text), Status (text)
jobaudit_table : JobAuditID (number), JobID (Number), FormID (Number)
There is a one to many relationship with jobaudit_table having multiple records for each JobID in job_table.
I have created a Group Header using the job_table.JobID and suppressed the detail section.
In the group header for each JobID I display the JobID, Manager, Status. I also use the below formula to determine if any records in the jobaudit_table has a record where FormID = 90. If so, I display "Yes". If not, "No".
So my report currently looks like.
JobID Manager Status Audit Performed
1 Manager 1 Closed N
2 Manager 2 Closed Y
Here are the formula's I use to determine if any records in jobaudit_table contains a record where FormID = 90.
@ja90exists
if {jobaudit_table.FormID} = 90 then 1else 0;
if sum({@ja90exists},{job_table.JobID}) = 0 then "No"else "Yes";
Everything so far works fine. What I would like to do now is add a hyperlink to a script to view the job audit when in the above report the "Audit Performed" column is "Yes"
So Report is now:
JobID Manager Status Audit Performed
1 Manager 1 Closed N
2 Manager 2 Closed Y (hyperlink to view audit)
I cannot figure out how to gather the valid JobAuditIDs where FormID = 90 grouped by JobID to be used in the Group Heading section of the report.
Also, it is unlikely, but possible that more than one job_audit record exists with FormID = 90 per JobID. So, my hyperlink could look like http://mysite.com/viewjobaudit.aspx?jobid=[jobaudit_table.JobAuditID],[jobaudit_table.JobAuditID] .
Thanks for any help. And if this post is not clear let me know and I will clarify.
wm5Post Author: bettername
CA Forum: Formula
Although I can't think of a way to get multiple hyperlinks, this should be a start. It (should) hyperlink to the last job/audit in the group that formID of 90. Oh, I assumed that the hyperlink should have been xxxx...jobID,jobAuditID!
I think there may be a way of getting hyperlinks to every "90" record, but that will involve a subreport, so lets try this first...
1 - everything from your group header to the group footer...
2 - add a formula into the group header that says:
whileprintingrecords;
stringvar jobauditID="";
stringvar jobID:=";
3 - Then add a formula to the details section:
whileprintingrecords;
stringvar jobauditID;
stringvar jobID;
if {jobaudit_table.FormID} = 90
then (jobID:=totext({job_table.job_id},0,""); jobauditID:=totext({jobaudit_table.jobaudit_id},0,"")
4 - Finally, on your "Audit Performed" formula, have a conditional hyperlink that says:
whileprintingrecords;
stringvar jobauditID;
stringvar jobID;
if {@audit performed} = "Y" then http://mysite.com/viewjobaudit.aspx?jobid=jobID","+jobauditID -
Subject area security validating users and groups from external table
Hi all.
I don't have practice to put question here, but there is one problem, that seems don't work correctly in OBIEE.
I'm trying to put users in groups within external table and this works fine.
I put security on the subject area level like this:
SA1 -> GroupA allow, Everyone not allow
SA2 -> GroupB allow, Everyone not allow
External table:
User----------Group
A---------GroupA;GroupB
B---------GroupB
Users A, B and GroupA, GroupB exists in the RPD, but I didn't put users inside them, I want this from table.
From the init block, external table I'm taking users and join them in the group. Same name users and groups are also in the presentation service.
When i connect with user A i don't see any subject area, when go to My Account i see in Group Membership/GroupA and GroupB, so it's readed from the external table.
Why in this case the subject area permission is not working?
It works if I explicitly put users in groups, in the RPD.
I have read this blog entry http://kpipartners.blogspot.com/2009/07/groups-webgroups-and-delivers.html and it is said that this works, but I'm interested how.
What should we have in the presentation part, administration, Manage Privileges -> Access within Oracle BI Answers option for those two subject area?
This doesn't work or something is missing:
Re: Security on Subject Areas
Regards
Goran
http://108obiee.blogspot.comWhat should we have in the presentation part, administration, Manage Privileges -> Access within Oracle BI Answers option for those two subject area?Yes, you should remove Everyone and add the relevant groups to each Subject Area. You don't need to set privileges in the RPD, in fact that's probably why it doesn't work for you. Leave your RPD Presentation Catalog as "Everyone" = Read as you will controlling access from the Presentation Services and it should work.
-
Material Group Difference MM03 (Table MARA) and Reservation (Table RESB)
Why material group at T-code MM03 (MARA-MATKL) difference at Table RESB ?
Table MARA-MATKL = 04
Table RESB-MATKL = 02
I checking MM03 not change about material group. I don't know some T-code can change material group link to table RESB.Dear Mr.Jutamas,
As per to my understanding,initially when the reservation was made for the
particular material ,material group - 02 in Basic Data 1 view would have been
present or maintained in the material master.
After that a change might have occured,i.e someone must have changed the
material group from 02 to 04.
So in MARA table the value is showing as 04 and in RESB its showing as 04.
Once after creating reservation ,if such changes are made,as far as i know that
will not get updated or reflected in RESB.
Better confirm the same,in MM03 - Display mode of the material and after going
into any one of the view,in the top menu check Environment - Display Changes -
you may get one or a list of changes that were made,along with the user,date &
time details.
<b>If useful reward points</b>
Regards
Mangal -
How to create checkbox group and table dynamically?
HI All
How to create checkbox group and table dynamically?
Regards
Ravihi
check this links for creating tables dnamically
How to Create a table dynamically?
Re: how to create a table dynamically in webdynpro
and for checkboxgroup
IWDTransparentContainer rootContainer =
(IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDCheckBox check = (IWDCheckBox)view.createElement(IWDCheckBox.class,"Check"+k);
//Here "check"+k k represents a unique value every time u create so that u wont get a duplicate instance
check.setChecked(false);
rootContainer.addChild(check);
or Re: adding checkboxes dynamically -
Handling substitution groups and Tables generation
Hi
This is concerning the generation of tables from xml schema containing "substitutionGroup" attributes and "extension" elements for
deriving from abstract types.
I want to know how the tables are generated when schema has subsitution groups.
I went through the generated tables and observed that it creates a table for each extension...but also generates a table for the head of the subsitution group.
This table would have columns for each of the members in the derivatives of the abstract type.This is resulting in more than 1000 columns in my case
Any suggestions?
Thanks
DevashishWhen a subsitution group is used each of the type of each of the elements in the substition group must be an extension of the type of the head element. In the case where the head type is based on an abstract empty complexType this makes no sense. Since the type inheritiance system implies that anywhere a parent type can appear it is legal for the chlild type to appear in it's place we have to create a storage structure for the head element which can handle any of the possible child types. This means that at the storage level we have to generate a table with a column for each possible descendant of the head element. This means that we are effectively restricting the number of direct elements and attributes that can be defined by members of the substition group to a number that is a little less than 1000.
This can be be seen in the first example below.
However in the case where the substition group contains no common element we can model this as choice. as is shown in the second XML Schema. Since every member of the choice is independant of the other members of the choice there is no need for the inheritance hierarchy in the type definitions. This means that each member of the choice can now be mapped to a seperate table. This structure allows for a choice with approxamately a 1000 entries and no practicle limits on the number of decendant elements and attributes for each member of the choice..
This can be seen in the second example bleow;
The key point is the number of columns in ROOT_TABLE. In the First Example it is 17, the fixed overhead plus the number of columns required to persist headType, member1Type and member2Type. In the Second example it is 12, the fixed overhead plus a REF XMLType to point at instances of member1Type and REF XMLType to point at instnaces of member2Type.
I hope this answers your question
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> column qualified_col_name format A64
SQL> column data_type format A40
SQL> --
SQL> set lines 150 pages 25 long 10000
SQL> --
SQL> begin
2 :schemaURL := 'testcase.xsd';
3 :schemaPath := '/public/testcase.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<?xml version="1.0" encoding="UTF-8"?>
5 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" attribute
FormDefault="unqualified" xdb:storeVarrayAsTable="true">
6 <xs:element name="root" type="rootType" xdb:defaultTable="ROOT_TABLE"/>
7 <xs:complexType name="rootType" xdb:SQLType="ROOT_T">
8 <xs:sequence>
9 <xs:element ref="head"/>
10 </xs:sequence>
11 </xs:complexType>
12 <xs:complexType name="headType" xdb:SQLType="HEAD_T" abstract="true"/>
13 <xs:complexType name="member1Type" xdb:SQLType="MEMBER1_T">
14 <xs:complexContent>
15 <xs:extension base="headType">
16 <xs:sequence>
17 <xs:element name="Member1.Child1" type="xs:string"/>
18 <xs:element name="Member1.Child2" type="xs:string"/>
19 </xs:sequence>
20 </xs:extension>
21 </xs:complexContent>
22 </xs:complexType>
23 <xs:complexType name="member2Type" xdb:SQLType="MEMBER2_T">
24 <xs:complexContent>
25 <xs:extension base="headType">
26 <xs:sequence>
27 <xs:element name="Member2.Child1" type="xs:string"/>
28 <xs:element name="Member2.Child2" type="xs:string"/>
29 </xs:sequence>
30 </xs:extension>
31 </xs:complexContent>
32 </xs:complexType>
33 <xs:element name="head" type="headType" xdb:defaultTable="GLOBAL_HEAD_TABLE"/>
34 <xs:element name="member1" type="member1Type" substitutionGroup="head" xdb:defaultTable="GLOBAL_MEMBER1_TABLE"/>
35 <xs:element name="member2" type="member2Type" substitutionGroup="head" xdb:defaultTable="GLOBAL_MEMBER2_TABLE"/>
36 </xs:schema>');
37 begin
38 if (dbms_xdb.existsResource(:schemaPath)) then
39 dbms_xdb.deleteResource(:schemaPath);
40 end if;
41 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
42 end;
43 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> --
SQL> desc ROOT_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "root") STORAGE Object-relational TYPE "ROOT_T"
SQL> --
SQL> desc ROOT_T
ROOT_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
head HEAD_T
SQL> --
SQL> desc HEAD_T
HEAD_T is NOT FINAL
HEAD_T is NOT INSTANTIABLE
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
SQL> --
SQL> desc GLOBAL_HEAD_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "head") STORAGE Object-relational TYPE "HEAD_T"
SQL> --
SQL> desc GLOBAL_MEMBER1_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "member1") STORAGE Object-relational TYPE "MEMBER1_T"
SQL> --
SQL> desc MEMBER1_T
MEMBER1_T extends SCOTT.HEAD_T
MEMBER1_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
Member1.Child1 VARCHAR2(4000 CHAR)
Member1.Child2 VARCHAR2(4000 CHAR)
SQL> --
SQL> desc GLOBAL_MEMBER2_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "member2") STORAGE Object-relational TYPE "MEMBER2_T"
SQL> --
SQL> desc MEMBER2_T
MEMBER2_T extends SCOTT.HEAD_T
MEMBER2_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
Member2.Child1 VARCHAR2(4000 CHAR)
Member2.Child2 VARCHAR2(4000 CHAR)
SQL> --
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'ROOT_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA ROOT_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."head" HEAD_T
SYS_TYPEID("XMLDATA"."head") RAW
"XMLDATA"."head"."SYS_XDBPD$" XDB$RAW_LIST_T
TREAT("XMLDATA"."head" AS "MEMBER2_T")."Member2.Child1" VARCHAR2
TREAT("XMLDATA"."head" AS "MEMBER2_T")."Member2.Child2" VARCHAR2
TREAT("XMLDATA"."head" AS "MEMBER1_T")."Member1.Child1" VARCHAR2
TREAT("XMLDATA"."head" AS "MEMBER1_T")."Member1.Child2" VARCHAR2
ACLOID RAW
OWNERID RAW
17 rows selected.
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'GLOBAL_MEMBER1_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA MEMBER1_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."Member1.Child1" VARCHAR2
"XMLDATA"."Member1.Child2" VARCHAR2
ACLOID RAW
OWNERID RAW
12 rows selected.
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'GLOBAL_MEMBER2_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA MEMBER2_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."Member2.Child1" VARCHAR2
"XMLDATA"."Member2.Child2" VARCHAR2
ACLOID RAW
OWNERID RAW
12 rows selected.
SQL> insert into ROOT_TABLE values( XMLType (
2 '<root>
3 <member1>
4 <Member1.Child1>AAA</Member1.Child1>
5 <Member1.Child2>BBB</Member1.Child2>
6 </member1>
7 </root>'))
8 /
1 row created.
SQL> insert into ROOT_TABLE values( XMLType (
2 '<root>
3 <member2>
4 <Member2.Child1>CCC</Member2.Child1>
5 <Member2.Child2>DDD</Member2.Child2>
6 </member2>
7 </root>'))
8 /
1 row created.
SQL> set long 1000 pages 20
SQL> --
SQL> select * from ROOT_TABLE
2 /
SYS_NC_ROWINFO$
<root>
<member1>
<Member1.Child1>AAA</Member1.Child1>
<Member1.Child2>BBB</Member1.Child2>
</member1>
</root>
<root>
<member2>
<Member2.Child1>CCC</Member2.Child1>
<Member2.Child2>DDD</Member2.Child2>
</member2>
</root>
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'testcase.xsd';
3 :schemaPath := '/public/testcase.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> call dbms_xmlSchema.deleteSchema(:schemaURL,4)
2 /
Call completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<?xml version="1.0" encoding="UTF-8"?>
5 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" attribute
FormDefault="unqualified" xdb:storeVarrayAsTable="true">
6 <xs:element name="root" type="rootType" xdb:defaultTable="ROOT_TABLE"/>
7 <xs:complexType name="rootType" xdb:SQLType="ROOT_T">
8 <xs:choice>
9 <xs:element ref="member1" xdb:SQLInline="false" xdb:defaultTable="MEMBER1_TABLE"/>
10 <xs:element ref="member2" xdb:SQLInline="false" xdb:defaultTable="MEMBER2_TABLE"/>
11 </xs:choice>
12 </xs:complexType>
13 <xs:complexType name="member1Type" xdb:SQLType="MEMBER1_T">
14 <xs:sequence>
15 <xs:element name="Member1.Child1" type="xs:string"/>
16 <xs:element name="Member1.Child2" type="xs:string"/>
17 </xs:sequence>
18 </xs:complexType>
19 <xs:complexType name="member2Type" xdb:SQLType="MEMBER2_T">
20 <xs:sequence>
21 <xs:element name="Member2.Child1" type="xs:string"/>
22 <xs:element name="Member2.Child2" type="xs:string"/>
23 </xs:sequence>
24 </xs:complexType>
25 <xs:element name="member1" type="member1Type" xdb:defaultTable="GLOBAL_MEMBER1_TABLE"/>
26 <xs:element name="member2" type="member2Type" xdb:defaultTable="GLOBAL_MEMBER2_TABLE"/>
27 </xs:schema>');
28 begin
29 if (dbms_xdb.existsResource(:schemaPath)) then
30 dbms_xdb.deleteResource(:schemaPath);
31 end if;
32 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
33 end;
34 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> --
SQL> desc ROOT_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "root") STORAGE Object-relational TYPE "ROOT_T"
SQL> --
SQL> desc ROOT_T
ROOT_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
member1 REF OF XMLTYPE
member2 REF OF XMLTYPE
SQL> --
SQL> desc GLOBAL_MEMBER1_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "member1") STORAGE Object-relational TYPE "MEMBER1_T"
SQL> --
SQL> desc MEMBER1_T
MEMBER1_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
Member1.Child1 VARCHAR2(4000 CHAR)
Member1.Child2 VARCHAR2(4000 CHAR)
SQL> --
SQL> desc GLOBAL_MEMBER2_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "member2") STORAGE Object-relational TYPE "MEMBER2_T"
SQL> --
SQL> desc MEMBER2_T
MEMBER2_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
Member2.Child1 VARCHAR2(4000 CHAR)
Member2.Child2 VARCHAR2(4000 CHAR)
SQL> --
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'ROOT_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA ROOT_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."member1" XMLTYPE
"XMLDATA"."member2" XMLTYPE
ACLOID RAW
OWNERID RAW
12 rows selected.
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'GLOBAL_MEMBER1_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA MEMBER1_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."Member1.Child1" VARCHAR2
"XMLDATA"."Member1.Child2" VARCHAR2
ACLOID RAW
OWNERID RAW
12 rows selected.
SQL> select qualified_col_name, data_type from user_tab_cols where table_name = 'GLOBAL_MEMBER2_TABLE'
2 /
QUALIFIED_COL_NAME DATA_TYPE
SYS_NC_OID$ RAW
SYS_NC_ROWINFO$ XMLTYPE
XMLEXTRA XMLTYPEEXTRA
"XMLEXTRA"."NAMESPACES" XMLTYPEPI
"XMLEXTRA"."EXTRADATA" XMLTYPEPI
XMLDATA MEMBER2_T
SYS_TYPEID("XMLDATA") RAW
"XMLDATA"."SYS_XDBPD$" XDB$RAW_LIST_T
"XMLDATA"."Member2.Child1" VARCHAR2
"XMLDATA"."Member2.Child2" VARCHAR2
ACLOID RAW
OWNERID RAW
12 rows selected.
SQL> insert into ROOT_TABLE values( XMLType (
2 '<root>
3 <member1>
4 <Member1.Child1>AAA</Member1.Child1>
5 <Member1.Child2>BBB</Member1.Child2>
6 </member1>
7 </root>'))
8 /
1 row created.
SQL> insert into ROOT_TABLE values( XMLType (
2 '<root>
3 <member2>
4 <Member2.Child1>CCC</Member2.Child1>
5 <Member2.Child2>DDD</Member2.Child2>
6 </member2>
7 </root>'))
8 /
1 row created.
SQL> set long 1000 pages 20
SQL> --
SQL> select * from ROOT_TABLE
2 /
SYS_NC_ROWINFO$
<root>
<member1>
<Member1.Child1>AAA</Member1.Child1>
<Member1.Child2>BBB</Member1.Child2>
</member1>
</root>
<root>
<member2>
<Member2.Child1>CCC</Member2.Child1>
<Member2.Child2>DDD</Member2.Child2>
</member2>
</root>
SQL>
SQL>
SQL> -
Need your help to confirm the table join rules on DocEntry and DocNum.
Hi guys,
I've done some study and awared table join rules on SBO documents, let me put in the followings:
(1) the table of documents head (i.e. ODLN) and line items (i.e. DLN1) can be joined via DocEntry/BaseEntry.
(2) the table of related documents (i.e. RDR1 and DLN1) can be joined via DocNum/BaseRef.
finnally, can we say that we can ONLY join table by DocEntry/BaseEntry or DocNum/BaseRef, and we should NOT use DocEntry/BaseRef.
Am I right? pls help to correct it for my misunderstanding.
Thanks.thanks for your help.
but I'm truly confused about why some table have both BaseRef and BaseEntry columns, some table only have DocEntry columns?
As I know, e.g. OWOR and WOR1, there have some series generated from NMM1, the value of DocEntry/DocNum in OWOR may not be the same, and we can only join OWOR/WOR1 via OWOR.DocEntry = WOR1.DocEntry.
So when to use (T0.DocEntry/T1.DocEntry), when to use (T0.DocEntry/T1.BaseEntry) and when to use (T0.DocNum/T1.BaseRef)? -
How to make two matrix and table into same group in SSRS
Hi
i need to dispaly to dispaly data matrix and table . but matrix data on first page and table data on second page.
how to achive this . if i give pagebreak for every new instance for matrix, only matrix data is getting dispalyed in one page and on the second page seocond record date is getting displayed. after all matrix data is displayed ( in separate pages) , table
data is being dispalyed.
but i want to display matrix data on first page and table data on the second page for the first record. for second record also it should display matrix data on 3rd page and table data on 4th page etc..
i mean how to make matrix and table data as same group. so that i can set "page break for new instamce" etc..
how to achive this in SSRS2008Hi Ramkanuganti,
From your description, you want to group both the matrix and table on the same field and add a page break between the two controls for each instance at run time.
To achieve your goal, we can display the matrix in a list and display the table in a nesting list. Please refer to the steps below:
Drag a “List” to the design surface. Drag the matrix into the top of the list (list1).
Drag a “”List” to the list1, under the matrix. Drag the table into the nesting list (list2).
Select “list1” and open the “Group Properties” from the “Row Groups” pane. Add the field on which you want to group the data. In the “Page Breaks” tab, select the “Between each instance of a group”.
Repeat step 3 to configure the “list2” using the same field. Additionally, please also select the “Also at the start of a group” option.
For more information about how to work with list, please refer to:
Adding a List
If you have any further questions, please feel free to ask.
Regards,
Mike Yin -
Can you select the max of a group by and mach it to another table?
I can't get my little head around this one. I have 2 tables
table 1:
T1ID col1 col2 col3
1 a t e
2 g y a
3 h r p
4 f u w
and table 2 that has many entries from table 1
Table 2:
T1ID ID col1
1 3 Y
1 2 M
1 1 H
3 2 W
3 1 E
I want the contents of table 1 with the value of col1 from table 2 where the ID is the highest?
so returning table 3:
ID col1 col2 col3 col1_from_table_3
1 a t e Y
2 g y a
3 h r p W
4 f u w
is this easy to do with a select statment?
Thanks for all of you help(in advance)
LTSQL> create table t1 (t1id,col1,col2,col3)
2 as
3 select 1, 'a', 't', 'e' from dual union all
4 select 2, 'g', 'y', 'a' from dual union all
5 select 3, 'h', 'r', 'p' from dual union all
6 select 4, 'f', 'u', 'w' from dual
7 /
Tabel is aangemaakt.
SQL> create table t2 (t1id,id,col1)
2 as
3 select 1, 3, 'Y' from dual union all
4 select 1, 2, 'M' from dual union all
5 select 1, 1, 'H' from dual union all
6 select 3, 2, 'W' from dual union all
7 select 3, 1, 'E' from dual
8 /
Tabel is aangemaakt.
SQL> select t1.t1id id
2 , max(t1.col1) keep (dense_rank last order by t2.id) col1
3 , max(t1.col2) keep (dense_rank last order by t2.id) col2
4 , max(t1.col3) keep (dense_rank last order by t2.id) col3
5 , max(t2.col1) keep (dense_rank last order by t2.id) col1_from_t2
6 from t1
7 , t2
8 where t1.t1id = t2.t1id (+)
9 group by t1.t1id
10 /
ID COL1 COL2 COL3 COL1_FROM_T2
1 a t e Y
2 g y a
3 h r p W
4 f u w
4 rijen zijn geselecteerd.Regards,
Rob.
Maybe you are looking for
-
Can I cut a file from a folder & copy it to another without leaving ori
Hi Can I cut a file form a folder and copy it into another folder without leaving the original in the 1st folder? I know I can copy it across. but I dont want to have to keep going back and deleting the original? Thanks
-
Can't access my account after time machine hard disk restore. HELP please.
i was attempting to partition my hard disk with boot camp when an error message appeared saying that it could not be partitioned and to backup my hard disk, reformat and restore using time machine, then run boot camp again. i did this and now i canno
-
Hello, one of the download files for CS6 is DesignWebPremium_CS6_LS16.7z which lists on the download site as being 4.6Gb. I have downloaded it twice with no reported errors but the file downloaded is only 489Mb. When I try to extract the install file
-
How to make your application multilanguage
Hi, i have an application under jdev 11g that uses resources bundle for the multilanguage. In my main page the user can choose the language to see. <af:selectOneChoice id="language" value="#{view.locale}" contentStyle="width:16em;"> <f:selectItems va
-
Why is my scrolling jerky and not smooth?
Hi, I just bought a refurbished MBPro early 2013 model. However I noticed that the scrolling is not very smooth when using multitouch scroll, and can be quite jerky, particularly with Safari (I am using Chrome). I have already tried restarting in Saf