Cartesian Join query optimization
Hello Experts!
I have a question about cartesian join query which might look a bit weird.
Assume the SQL query like that:
SELECT DISTINCT A.NAME
FROM A, B, C;
Here we have cartesian join for 3 tables A, B and C.
It looks to me, in order to get the result for such a particular SQL tables/sets B and C need to be accessed only to ensure they return at least 1 row (otherwise result set is empty), query table A, but there is no actual need to join the data.
If you run such a query Oracle is doing full table scans and actually joins the data.
Yes, DBMS is doing exactly what you are asking for, but I wonder if there is any way (SQL hint or db parameter or anything else) to enforce more optimal access path here?
Obvious solution to remove B and C tables from the SELECT statement is not acceptable. :-)
Thank you!
Your statement in the other thread indicates you don't understand how the BI prompts actually work because you say you want it to do something that doesn't make sense for it to do.
Of course Product and Account levels will be constrained to the interval you specified. It wouldn't make sense for them not to be. Because that would mean returning data for based on product and account levels that has a different open data range than what you specified.
All UI prompt dialogs I have seen use AND relationships between the parameters. If there are three parameters (A, B, C) then the ultimate relationship is 'A AND B AND C'; not 'A OR (B AND C)', 'A AND (B OR C)', 'A OR (B OR C).
Unless the tool allows you to select OR relationships you need to use a separate dialog box (parameter dialog) for each condition set.:-)
I understand how BI prompts work and basically agree on your comment, but there are two problems here:
1. I need to convince the customer his original requirements are not valid. Customer want it to work different way and there are some reasons why.
2. There are pretty large dimensions and fact tables used here, so when I choose filter criteria for the Product (which is small table) to populate/recalculate prompt values, large SR dimension and fact tables are joined too, and if there are Account dimension filters added, huge Account dimension will be added as well. This looks to be a bit sub-optimal for just populating the Product prompt values.
Of course, technically this is solvable, but requires to put some extra effort and does not solve the 1st issue.
That other link doesn't explain the sample code you posted in this thread. Post the actual query that is being generated and the query that you want to actually use.This is what is generated:
>
select distinct T311691.X_CUST_SUBTYPE as c1
from
WC_LOV_SR_AREA_H T311695,
WC_LOV_PROD_H T311687,
WC_LOV_CUST_TYPE_H T311691,
W_SRVREQ_D T302384 /* Dim_W_SRVREQ_D */
where ( T311687.LEV1 = 'Product X' and T311691.X_CUST_TYPE = 'Business' and T302384.OPEN_DT between TO_DATE('2012-03-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2012-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
order by c1
>
This is what is actually needed to query this data:
>
select distinct T311691.X_CUST_SUBTYPE as c1
from
WC_LOV_CUST_TYPE_H T311691
where ( T311691.X_CUST_TYPE = 'Business' )
order by c1
Similar Messages
-
Puzzled By Cartesian Join In Query
If I do this query:
SELECT count(*)
FROM
mode_change_history psch
JOIN mode_link psl USING (mode_index)
WHERE
psch.date_changed >= TO_TIMESTAMP ('2008-03-03 05:00:00.000', 'YYYY-MM-DD HH24:MI:SS.FF');
The query takes less than a second and I get the desired results. If I modify the query by adding an additional join to the analysts table, like this:
SELECT count(*)
FROM
mode_change_history psch
JOIN mode_link psl USING (mode_index)
JOIN analysts a USING (analyst_id)
WHERE
psch.date_changed >= TO_TIMESTAMP ('2008-03-03 05:00:00.000', 'YYYY-MM-DD HH24:MI:SS.FF');
The query takes too long (about a minute) and generates a cartesian product(according to the explain plan) when joining the analysts table.
Notes:
I've removed the column names from the SELECT clause and replaced it with a count(*) just to simply this example.
Relevant info on the tables being joined:
mode_change_history columns
mode_index
date_changed
analyst_id
justification
change_type
Primary key on this table: mode_index,date_changed,analyst_id
Approximate rows in table: 50,000
mode_link columns
mode_index
mode_name
parameter_set_id
Primary key on this table is: mode_index
Approximate rows in table: 20,000
analysts columns
analyst_id
user_name
full_name
Primary key on this table is: analyst_id
Approximate rows in table: 500
As you can see, none of the tables have many rows.
After joining the first two tables listed in the query the result of the join would have rows containing mode_index (from mode_change_history and mode_link tables) that satisfy the WHERE clause. This intermediate result set should include the additional column analyst_id from the mode_change_history table. Then I would expect the RDBMS to join the rows from the analysts table that have analyst_id's in the intermediate result set. This does not appear to be happening since I'm seeing the cartesian join line show up in the execution plan.
Any ideas on what's going on?
I would post the explain plans but the Oracle instance is on a network that is not connected to the Internet so I can't easily post any output.
Thank youI don't use them myself. but I did have to debug somebody else's code which was giving all kinds of random results. natural three way join (sounds dirty) - ha!
also, I've seen discrepancies between the manuals for different versions on the syntax and rules. one manual states that the USING clause is only valid for outer joins. another release states that it's good for inner and outer. I've also seen differences regarding the use of the word NATURAL.
the bug it isn't that the optimizer uses a merge join carteian to resolve it (which could still give the correct answer, but possibly not with optimal performance). it's that it screws up the join criteria and returns a cartesian product result set.
my opinion - screw ansi, I'm using oracle syntax. and if some new guy with a t-sql background doesn't like it, tough. I came from a C & Pascal background and had an oracle manual thrown in my lap (it was long enough ago that manuals were still printed, and luckily, being v5, the manuals were small and didn't damage anything). -
Merge cartesian join in query plan
Hi All
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
W are using many GTT's in our code, the query plan have Merge Cartesain join showing cardinality as '1' which is incorrect, as GTT tables have many rows. Due to this query is taking ages to execute.
I am trying to sue dynamic sampling, but it doesn't seem to work.
please help on this.user8650395 wrote:
Hi All
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
W are using many GTT's in our code, the query plan have Merge Cartesain join showing cardinality as '1' which is incorrect, as GTT tables have many rows. Due to this query is taking ages to execute.
I am trying to sue dynamic sampling, but it doesn't seem to work.
please help on this.Interesting.
There was a a thread a day or two ago about when dynamic sampling does not work. You can search OTN for it if you like. Also check the docs to make sure that dynamic sampling works with GTTS
One problem with GTTS is getting accurate statistics. Have you considered using DBMS_STATISTICS to set the statistics on the table to adjust the cardinality?
Your cardinality of 1 sounds incorrect. In theory a cartesian join against one row should be painelss; unfortunately your cardinality figure seems to be off! Sometimes in cases like yours the cost-based optimizer will choose a Cartesian join even when the table joins are properly specified. -
Could anyone help me to avoid Cartesian join in this query?
Hi, guys:
Could you help me on this query? I must generate a Cartesian join, but I do not know why it happens. dt.debtorkey, cl.clientkey, inv.invoicekey, ag.agingkey are primary keys of each table. The problem is: I got same tuple for 8 times.
select dt.debtorkey, cl.clientkey, inv.invoicekey, ag.agingkey, dt.DebtorNo, dt.Name as "debtor Name", dt.State, cl.ClientNo, cl.Name as "Client Name", inv.InvNo, inv.PurchOrd, inv.Amt,
to_char(inv.InvDate, 'MM-DD-YY') invoice_date, to_char(ag.DateLastBuy, 'MM-DD-YY') aging_lastbuy, to_char(ag.DateLastPmt, 'MM-DD-YY') aging_lastpmt
from aging ag, invoices inv, debtors dt, clients cl
where ag.clientkey=cl.clientkey
and ag.debtorkey=dt.debtorkey
and inv.clientkey=cl.clientkey
and inv.debtorkey=dt.debtorkey
and ((inv.InvDate>=to_date(:P16_DP_IDF_START_DATE, 'MM/DD/YYYY')
and inv.InvDate<=to_date(:P16_DP_IDF_END_DATE, 'MM/DD/YYYY')
and ag.DateLastBuy=to_date(:P16_DP_IDF_LAST_BUY,'MM/DD/YYYY')
order by dt.name;Thanks a lot!Hi,
Thanks for help. I am sorry for that I do not know how to upload a picture of explain plan. I am struggling to find how to provide sample data. I hope this data format could be at least useful.
"DEBTORKEY","CLIENTKEY","INVOICEKEY","AGINGKEY","DEBTORNO","debtor Name","STATE","CLIENTNO","Client Name","INVNO","PURCHORD","AMT","INVOICE_DATE"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744212,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960590","LK1-17225",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744213,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960591","LK1-17241",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"
8,2741,744214,276807,"0538","MJN Services, Inc.","UT","2696","Pompano Logistics, LLC","26960592","LK1-17224",1700,"09-25-12"I do not know why the tuples with same primary key repeat 8 times.
Edited by: lxiscas on Oct 24, 2012 4:08 PM
Edited by: lxiscas on Oct 24, 2012 4:10 PM -
CacheSplitMemoryReader - Cartesian join?
Hi,
We have a process where we run multiple matches on the input file, and then group number from each match is sent to a query transform to do an outer join before it is sent to associative match transform.
The process runs fine with small data set, but when we ran it for a production size file, the process ran for about 15 hours.
Looking at the monitor logs, we see a very large number against "CacheSplitMemoryReader".
While testing it with small set (say, 11 records in the input file), I see "121" rowcount against "CacheSplitMemoryReader".
Though I am not sure what "CacheSplitMemoryReader" means, my guess is that it is related to the join. And for some reason, while joining all the four input streams, DS decides to do a Cartesian join?
Though, the output is fine - with 11 records coming out of associative match.
We have tried changing outer join order in the query transform to see if that makes any difference. But so far, everytime it ends up with 121 records for "CacheSplitMemoryReader".
Any insight into what is happening and how to avoid it?
Thanks,
Gaurav
Edit: This is for DataService 12.2.0.1
Edited by: Gaurav Pandit on Nov 4, 2009 2:53 PMHello Gaurav,
I am curious why you are doing this join at all.
If you are trying to optimize the peformance of Associate, I recommend bypassing the rows that have no group number. In other words Associate should receive only the rows that have at least one group number populated. And then you will have to Merge back the rows.
I also recommend referring our bluprints posted here SAP Data Services Blueprints for example usage of Match and Associate. Please take a look at jobs named *_MatchAssociative. Here you will see how specific rows are bypassed and merged back for different Match transform. Similar principle can be applied for Associate. The Case condition will be based on Group Numbers.
Thanks,
Abhiram -
Hi
below query is running 1 minutes on test server however it is stucking on production for more than 8 hours .
I compared explain plan for both queries ,on test server,optimizer is using hash join however on production ,optimizer is using Merge Cartesian join .
I tried query with ordered hit ,we get rid of mergecartesian join but cost got increased
now please advice ,if we should go by this ordered hit method on production or not not
or suggets any other ways .
below is query
SELECT DISTINCT acct_promo_hdr.row_id, '401000', 'EXPORTED',
acct_promo_hdr.src_num, 'PLAN_ACCOUNT_PROMOTION',
promo_hdr_org.NAME
FROM siebel.s_src acct_promo_hdr,
siebel.s_mdf_alloc deal,
siebel.s_bu promo_hdr_org
-- siebel.s_contact contact,
-- siebel.s_user usr
WHERE acct_promo_hdr.sub_type = 'PLAN_ACCOUNT_PROMOTION'
AND acct_promo_hdr.row_id = deal.promo_id
AND acct_promo_hdr.bu_id = promo_hdr_org.row_id
-- AND acct_promo_hdr.created_by = contact.row_id
-- AND contact.row_id = usr.row_id
AND EXISTS (
SELECT 1
FROM approval acb_approval
WHERE acb_approval.status NOT IN
('11', '12', '65', '77')
AND acct_promo_hdr.src_num =
acb_approval.commit_num)
AND deal.status_cd IN
('Cancel',
'Cancelled',
'Committed',
'On Hold',
'Processing Claim',
'Paid In Part',
'Paid In Full',
'Hold'
explain plan on production
PLAN_TABLE_OUTPUT
Plan hash value: 115701554
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 133 | 207 (2)| 00:00:03 |
| 1 | HASH UNIQUE | | 1 | 133 | 207 (2)| 00:00:03 |
| 2 | NESTED LOOPS | | | | | |
| 3 | NESTED LOOPS | | 1 | 133 | 206 (1)| 00:00:03 |
| 4 | NESTED LOOPS | | 1 | 112 | 205 (1)| 00:00:03 |
| 5 | MERGE JOIN CARTESIAN | | 1 | 57 | 67 (2)| 00:00:01 |
| 6 | SORT UNIQUE | | 1 | 30 | 64 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL | APPROVAL | 1 | 30 | 64 (0)| 00:00:01 |
| 8 | BUFFER SORT | | 3 | 81 | 3 (34)| 00:00:01 |
| 9 | TABLE ACCESS FULL | S_BU | 3 | 81 | 2 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID| S_SRC | 1 | 55 | 137 (0)| 00:00:02 |
|* 11 | INDEX RANGE SCAN | S_SRC_U2 | 1 | | 137 (0)| 00:00:02 |
|* 12 | INDEX RANGE SCAN | S_MDF_ALLOC_F8 | 12 | | 1 (0)| 00:00:01 |
|* 13 | TABLE ACCESS BY INDEX ROWID | S_MDF_ALLOC | 11 | 231 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
7 - filter("ACB_APPROVAL"."STATUS"<>'11' AND "ACB_APPROVAL"."STATUS"<>'12' AND
"ACB_APPROVAL"."STATUS"<>'65' AND "ACB_APPROVAL"."STATUS"<>'77')
11 - access("ACCT_PROMO_HDR"."BU_ID"="PROMO_HDR_ORG"."ROW_ID" AND
"ACCT_PROMO_HDR"."SUB_TYPE"='PLAN_ACCOUNT_PROMOTION')
filter("ACCT_PROMO_HDR"."SUB_TYPE"='PLAN_ACCOUNT_PROMOTION' AND
"ACB_APPROVAL"."COMMIT_NUM"=TO_NUMBER("ACCT_PROMO_HDR"."SRC_NUM"))
12 - access("ACCT_PROMO_HDR"."ROW_ID"="DEAL"."PROMO_ID")
13 - filter("DEAL"."STATUS_CD"='Cancel' OR "DEAL"."STATUS_CD"='Cancelled' OR
"DEAL"."STATUS_CD"='Committed' OR "DEAL"."STATUS_CD"='Hold' OR "DEAL"."STATUS_CD"='On
Hold' OR "DEAL"."STATUS_CD"='Paid In Full' OR "DEAL"."STATUS_CD"='Paid In Part' OR
"DEAL"."STATUS_CD"='Processing Claim')
35 rows selected.pujakhetan wrote:
Tables are analysed on production .Well, the stats are indicating to the optimizer that the filter at #7 (<tt>ACB_APPROVAL_STATUS {noformat}<{noformat}> '11'</tt> etc) will return 1 row (usually indicating it thinks there are no rows to process), so if that is not the case then something has gone wrong. I'm guessing the 'good' plan you see in test has higher cardinality figures?
I tried query with ordered hit, we get rid of merge cartesian join but cost got increased nowIgnore the 'cost', it is just a figure calculated by the optimizer to indicate the relative resources required by different query plans - according to the available stats - and if those stats are out or something else is confusing it then the figure will be meaningless. Look at it this way - if the cost calculation was right, your query would already have the best plan.
Also the problem was not the join order but the join method, so I don't see an 'ordered' hint necessarily helping.
btw placing <tt></tt> tags around your code and execution plan will make it a lot easier to read. -
Grus help needed in finding the queries with Cartesian joins
Hi
I have a reporting tool in which users are allowed to put the joins on the views and add some sub queries that produces a Cartesian product. Is there any tool or way that I can stop the execution of those query before it is being executed for example
Step 1 ) user creates a query
step2 ) user submits it
step 3) by any tool or any check if Cartesian join is found the query execution is stopped and notify the user that the query is not good if no problem executes the query.
I really need help in step 3. I am on 9i release2.
Any help or suggestions will be highly appreciated.I Agree with Gasparotto, you should limit the resource consume.
You must understand that cartesian join, isn´t always a BAD guy, sometimes you need it.
If your developers are in trouble with handle the join , think about NATURAL JOIN, may be it helps you
Regards
Helio Dias -
Hi friends,
I need to restrict the report according to the user who logs in to the application. But only for the ADMIN user i need to show all the records except with the status which is not in "CREATED', i need to show all the records to the admin with other status other than the 'CREATED" status.
For that i tried with the below query
select
'' "Null",
"REQUEST_ID",
"REQUEST_TYPE_NAME",
"REQUEST_NUMBER",
"REQUEST_CLASS_NAME",
"REQUEST_STATUS_NAME",
"REQUEST_DATE"
from XXHY_AMS_REQ_DET_V , apps.fnd_user xx
where /*request_number like nvl(:P1_REQUEST_NUMBER,'%')
and
REQUEST_STATUS_CODE like nvl(:P1_REQUEST_STATUS,'%')
and
lower(REQUEST_DATE) LIKE NVL(lower(:P1_REQUEST_DATE), '%')
and */requestor_person_id = xx.employee_id or
lower(xx.user_name) = lower(:APP_USER) or
exists (select 1 from apps.per_all_people_f papf,
apps.per_all_assignments_f paaf,
apps.per_all_people_f supf,
apps.pqh_roles rls,
apps.per_people_extra_info pei,
apps.fnd_user a, XXHY_AMS_REQ_DET_V b
where papf.person_id = paaf.person_id and pei.person_id = paaf.person_id
and nvl(paaf.supervisor_id, papf.person_id) = supf.person_id
and sysdate between papf.effective_start_date and papf.effective_end_date
and sysdate between paaf.effective_start_date and paaf.effective_end_date
and sysdate between supf.effective_start_date and supf.effective_end_date
and a.employee_id = papf.person_id
and lower(a.user_name) = lower(:APP_USER)
and information_type = 'PQH_ROLE_USERS' and paaf.person_id = b.requestor_person_id and lower(b.request_status_code) not in ('created')
and rls.role_id = to_number (pei.pei_information3)
and rls.role_id = to_number (pei.pei_information3) and rls.role_name like 'XXHW_AMS_ADMIN')
order by 1
In the above query i used the keyword :APP_USER which identifies the user who logs in APEX.
Also i have a role named XXHW_AMS_ADMIN, which identifies the user under the admin category.
So, according to my query, if the user is not in the admin category means, it has to show only the records raised by him. If the user is in the admin category means then it has to show all the records of all the users other than the status which is not in 'CREATED'.
But my above query is resulting in cartesian join, if i check with the admin username.
But it fetches the correct result if i checked with the user who is not in the admin category.
I dont know why the cartesian join is occuring if i check with the admin user.
Suppose if i tried to run the query separately which is beneath the EXIST condition* for checking the admin user means, then it is recognizing the admin. But i dont know why it is not working in my above query.*
select 1 from apps.per_all_people_f papf,
apps.per_all_assignments_f paaf,
apps.per_all_people_f supf,
apps.pqh_roles rls,
apps.per_people_extra_info pei,
apps.fnd_user a, XXHY_AMS_REQ_DET_V b
where papf.person_id = paaf.person_id and pei.person_id = paaf.person_id
and nvl(paaf.supervisor_id, papf.person_id) = supf.person_id
and sysdate between papf.effective_start_date and papf.effective_end_date
and sysdate between paaf.effective_start_date and paaf.effective_end_date
and sysdate between supf.effective_start_date and supf.effective_end_date
and a.employee_id = papf.person_id
and lower(a.user_name) = lower(:APP_USER)
and information_type = 'PQH_ROLE_USERS' and paaf.person_id = b.requestor_person_id and lower(b.request_status_code) not in ('created')
and rls.role_id = to_number (pei.pei_information3)
and rls.role_id = to_number (pei.pei_information3) and rls.role_name like 'XXHW_AMS_ADMIN')
order by 1what might be wrong in my query.
Brgds,
MiniI was using SQL Developer so i used colon.
For Sql plus I changed it to & and it is working as expected
SQL> with t_user as
select 1 as person_id, 'P1' as user_name from dual union all
select 2,'P2' from dual union all
select 3,'P3' from dual union all
select 4,'P4' from dual union all
select -1,'ADMIN' from dual
t_req_data as
select 1 as person_id, 'created' as request_status_code, sysdate-1 as some_data from dual union all
select 1 , 'updated' , sysdate-0.5 from dual union all
select 2 , 'deleted' , sysdate from dual union all
select -1 , 'created' , sysdate from dual union all
select -1 , 'updated' , sysdate from dual union all
select -1 , 'created' , sysdate - 21 from dual union all
select -1 , 'updated' , sysdate - 21 from dual union all
select 2 , 'deleted' , sysdate from dual
SELECT
tu.person_id,
tu.user_name,
trq.request_status_code,
trq.some_data
FROM
t_user tu,
t_req_data trq
WHERE
tu.person_id = trq.person_id
AND
&in_user = 'ADMIN'
AND request_status_code != 'created'
OR
&in_user != 'ADMIN'
AND &in_user = user_name
Enter value for in_user: 'ADMIN'
old 33: &in_user = 'ADMIN'
new 33: 'ADMIN' = 'ADMIN'
Enter value for in_user: 'ADMIN'
old 38: &in_user != 'ADMIN'
new 38: 'ADMIN' != 'ADMIN'
Enter value for in_user: 'ADMIN'
old 39: AND &in_user = user_name
new 39: AND 'ADMIN' = user_name
PERSON_ID USER_ REQUEST SOME_DATA
1 P1 updated 13-DEC-2011 22:14:32
2 P2 deleted 14-DEC-2011 10:14:32
-1 ADMIN updated 14-DEC-2011 10:14:32
-1 ADMIN updated 23-NOV-2011 10:14:32
2 P2 deleted 14-DEC-2011 10:14:32
SQL> -
HI, I have an XMLType column that has the following XML structure:
<Client>
<Report id = "01">
<Item id = "01" Description = ",a.mdfbnelt;yuk" </Item>
<Item id = "02" Description = "AAAAA;yuk" </Item>
<Item id = "03" Description = "XXXXX" </Item>
</Report>
<Report id = "02">
<Item id = "01" Description = ",ABCDEF" </Item>
<Item id = "02" Description = "JHIKLM" </Item>
<Item id = "03" Description = "OPQRST" </Item>
</Report>
</Client>
I would like to extract and insert data into the following file
Table MyTable(Client, Report_id, Item_id, Description)
So I created the following query
SELECT
extractValue(VALUE(x), '/Client/@id')) Client,
extractValue(VALUE(d), '/Report/@id') Report,
extractValue(VALUE(e), '/Item/@id') Description,
extractValue(VALUE(e), '/Item/@Description) Description
FROM XMLDOC2 x,
TABLE(xmlsequence(extract(VALU*E(x), '/Client/Report'))) d,
TABLE(xmlsequence(extract(VALU*E(x), '/Client/Report/Item'))) e
But I get the cartesian product of the reports and the items. I would
like to get the items related to a reports AND the report id on the
same line. If it is not possible, I would like to filter out the items
belonging to report; some kind of where clause.
Anybody has an idea?
regds,
Santhoshkumar.G.-- Xml format
<ITEMLIST>
<ITEM>
<EXTERNALID>ARSH0001</EXTERNALID>
<DESCRIPTION>WHITE DIAGEO SHIRT</DESCRIPTION>
<MATYPE>ZFGM</MATYPE>
<TAXCD>1</TAXCD>
<BRANDID>AR</BRANDID>
<UOMID>PC</UOMID>
<PRODUCTHIERARCHY>METOPSSHFASHN00895</PRODUCTHIERARCHY>
<MANUFACTURER1>FASHION</MANUFACTURER1>
<COLOR>WHITE</COLOR>
<THEME></THEME>
<COLLECTION>empty</COLLECTION>
<FIT></FIT>
<SEASON>S06</SEASON>
<PRDGRP>SH</PRDGRP>
<PRDCOLL>TOPS</PRDCOLL>
<TARGET>ME</TARGET>
<GRID>GRID01</GRID>
<SUBITEM size="38FS" quality="Q2" barcode="100051050" price=" 895.00"></SUBITEM>
<SUBITEM size="38FS" quality="Q3" barcode="100051051" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q2" barcode="100051052" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q3" barcode="100051053" price=" 895.00"></SUBITEM>
<SUBITEM size="40FS" quality="Q2" barcode="100051054" price=" 895.00"></SUBITEM>
<SUBITEM size="40FS" quality="Q3" barcode="100051055" price=" 895.00"></SUBITEM>
<SUBITEM size="42FS" quality="Q2" barcode="100051056" price=" 895.00"></SUBITEM>
<SUBITEM size="42FS" quality="Q3" barcode="100051057" price=" 895.00"></SUBITEM>
<SUBITEM size="44FS" quality="Q2" barcode="100051058" price=" 895.00"></SUBITEM>
<SUBITEM size="44FS" quality="Q3" barcode="100051059" price=" 895.00"></SUBITEM>
<SUBITEM size="46FS" quality="Q2" barcode="100051060" price=" 895.00"></SUBITEM>
<SUBITEM size="46FS" quality="Q3" barcode="100051061" price=" 895.00"></SUBITEM>
<SUBITEM size="48FS" quality="Q2" barcode="100051062" price=" 895.00"></SUBITEM>
<SUBITEM size="48FS" quality="Q3" barcode="100051063" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q1" barcode="8901208428516" price=" 895.00"></SUBITEM><SUBITEM size="40FS" quality="Q1" barcode="8901208428523" price=" 895.00"></SUBITEM><SUBITEM size="42FS" quality="Q1" barcode="8901208428530" price=" 895.00"></SUBITEM><SUBITEM size="44FS" quality="Q1" barcode="8901208428547" price=" 895.00"></SUBITEM><SUBITEM size="46FS" quality="Q1" barcode="8901208428554" price=" 895.00"></SUBITEM><SUBITEM size="48FS" quality="Q1" barcode="8901208428561" price=" 895.00"></SUBITEM><SUBITEM size="38FS" quality="Q1" barcode="8901208428578" price=" 895.00"></SUBITEM></ITEM>
<ITEM>
<EXTERNALID>ARSH0002</EXTERNALID>
<DESCRIPTION>BLACK DIAGEO SHIRT</DESCRIPTION>
<MATYPE>ZFGM</MATYPE>
<TAXCD>1</TAXCD>
<BRANDID>AR</BRANDID>
<UOMID>PC</UOMID>
<PRODUCTHIERARCHY>METOPSSHFASHN00895</PRODUCTHIERARCHY>
<MANUFACTURER1>FASHION</MANUFACTURER1>
<COLOR>BLACK</COLOR>
<THEME></THEME>
<COLLECTION>empty</COLLECTION>
<FIT></FIT>
<SEASON>S06</SEASON>
<PRDGRP>SH</PRDGRP>
<PRDCOLL>TOPS</PRDCOLL>
<TARGET>ME</TARGET>
<GRID>GRID01</GRID>
<SUBITEM size="38FS" quality="Q2" barcode="100051078" price=" 895.00"></SUBITEM>
<SUBITEM size="38FS" quality="Q3" barcode="100051079" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q2" barcode="100051080" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q3" barcode="100051081" price=" 895.00"></SUBITEM>
<SUBITEM size="40FS" quality="Q2" barcode="100051082" price=" 895.00"></SUBITEM>
<SUBITEM size="40FS" quality="Q3" barcode="100051083" price=" 895.00"></SUBITEM>
<SUBITEM size="42FS" quality="Q2" barcode="100051084" price=" 895.00"></SUBITEM>
<SUBITEM size="42FS" quality="Q3" barcode="100051085" price=" 895.00"></SUBITEM>
<SUBITEM size="44FS" quality="Q2" barcode="100051086" price=" 895.00"></SUBITEM>
<SUBITEM size="44FS" quality="Q3" barcode="100051087" price=" 895.00"></SUBITEM>
<SUBITEM size="46FS" quality="Q2" barcode="100051088" price=" 895.00"></SUBITEM>
<SUBITEM size="46FS" quality="Q3" barcode="100051089" price=" 895.00"></SUBITEM>
<SUBITEM size="48FS" quality="Q2" barcode="100051090" price=" 895.00"></SUBITEM>
<SUBITEM size="48FS" quality="Q3" barcode="100051091" price=" 895.00"></SUBITEM>
<SUBITEM size="39FS" quality="Q1" barcode="8901208428653" price=" 895.00"></SUBITEM><SUBITEM size="40FS" quality="Q1" barcode="8901208428660" price=" 895.00"></SUBITEM><SUBITEM size="42FS" quality="Q1" barcode="8901208428677" price=" 895.00"></SUBITEM><SUBITEM size="44FS" quality="Q1" barcode="8901208428684" price=" 895.00"></SUBITEM><SUBITEM size="46FS" quality="Q1" barcode="8901208428691" price=" 895.00"></SUBITEM><SUBITEM size="48FS" quality="Q1" barcode="8901208428707" price=" 895.00"></SUBITEM><SUBITEM size="38FS" quality="Q1" barcode="8901208428714" price=" 895.00"></SUBITEM></ITEM>
</ITEMLIST>
-- Sql
SELECT extract(value(d), '//EXTERNALID/text()').getStringVal() AS EXTERNALID,
extract(value(d), '//DESCRIPTION/text()').getStringVal() AS DESCRIPTION,
extract(value(d), '//MATYPE/text()').getStringVal() AS MATYPE,
extract(value(d), '//TAXCD/text()').getStringVal() AS TAXCD,
extract(value(d), '//BRANDID/text()').getStringVal() AS BRANDID,
extract(value(d), '//UOMID/text()').getStringVal() AS UOMID,
extract(value(d), '//PRODUCTHIERARCHY/text()').getStringVal() AS PRODUCTHIERARCHY,
extract(value(d), '//MANUFACTURER1/text()').getStringVal() AS MANUFACTURER1,
extract(value(d), '//COLOR/text()').getStringVal() AS COLOR,
extract(value(d), '//THEME /text()').getStringVal() AS THEME ,
extract(value(d), '//COLLECTION/text()').getStringVal() AS COLLECTION,
extract(value(d), '//FIT/text()').getStringVal() AS FIT,
extract(value(d), '//SEASON/text()').getStringVal() AS SEASON,
extract(value(d), '//PRDGRP/text()').getStringVal() AS PRDGRP,
extract(value(d), '//PRDCOLL/text()').getStringVal() AS PRDCOLL,
extract(value(d), '//TARGET/text()').getStringVal() AS TARGET,
extract(value(d), '//GRID/text()').getStringVal() AS GRID,
extract(value(z), '//@size').getStringVal() AS size_cd,
extract(value(z), '//@quality').getStringVal() AS quality,
extract(value(z), '//@barcode').getStringVal() AS barcode,
extract(value(z), '//@price').getStringVal() AS price
FROM xml_tab x,
table(xmlsequence(extract(value(x), '//ITEMLIST/ITEM'))) d,
table(xmlsequence(extract(value(x), '//ITEM/SUBITEM')))z
The above sql gives me a cartesian join for all the subitems to the items tag.
i.e.,
externalid
ARSH0001 -- 2 * 12 times for one record.
Pls give me a solution. I am struggling on this.
Please.
Regds,
Santhoshkumar.G. -
Outer/Cartesian Join using same table
Hi All,
I'm needing to write a query, which is kind of like an outer join/cartesian join that essentially tags each customer in my database with a flag indicating whether they have received a particular product for a given year. There are 8 products so for each distinct customer_id in my database I want 8 records, with a 'Yes' or 'No' indicating whether they have received this product or not. Currently, for a given year, if a customer only receives 2 out of the 8 products there will be two records for that individual but I want 8 records for each individual so that each product is shown to either have been received or not received by the customer. This is the table format I'm looking for:
CUSTOMER_ID PRODUCT_CD PRODUCT_RECEIVED_FLAG YEAR
999999999 1 Y 2010
999999999 2 N 2010
999999999 3 N 2010
999999999 4 N 2010
999999999 5 N 2010
999999999 6 N 2010
999999999 7 Y 2010
999999999 8 Y 2010
888888888 1 N 2010
888888888 2 N 2010
888888888 3 Y 2010
888888888 4 Y 2010
888888888 5 N 2010
888888888 6 N 2010
888888888 7 Y 2010
888888888 8 Y 2010
777777777 1 Y 2010
777777777 2 Y 2010
777777777 3 Y 2010
777777777 4 Y 2010
777777777 5 Y 2010
777777777 6 Y 2010
777777777 7 N 2010
777777777 8 N 2010Thanks,
EdI am in good mood today ;) :
with customer as (
select '999999999' customer_id from dual union all
select '888888888' from dual union all
select '777777777' from dual
product as (
select level product_cd from dual connect by level <= 8
orders as (
select '999999999' customer_id,1 product_cd,2010 year from dual union all
select '999999999',7,2010 from dual union all
select '999999999',8,2010 from dual union all
select '888888888',3,2010 from dual union all
select '888888888',4,2010 from dual union all
select '888888888',7,2010 from dual union all
select '888888888',8,2010 from dual union all
select '777777777',1,2010 from dual union all
select '777777777',2,2010 from dual union all
select '777777777',3,2010 from dual union all
select '777777777',4,2010 from dual union all
select '777777777',5,2010 from dual union all
select '777777777',6,2010 from dual union all
select '777777777',7,2010 from dual union all
select '777777777',8,2010 from dual
-- end of on-the-fly data sample
select c.customer_id,
p.product_cd,
nvl2(o.product_cd,'Y','N') product_received_flag,
y.year
from customer c
cross join
product p
cross join
select distinct year
from orders
) y
left join
orders o
on (
c.customer_id = o.customer_id
and
p.product_cd = o.product_cd
and
y.year = o.year
order by y.year,
c.customer_id desc,
p.product_cd
CUSTOMER_ PRODUCT_CD P YEAR
999999999 1 Y 2010
999999999 2 N 2010
999999999 3 N 2010
999999999 4 N 2010
999999999 5 N 2010
999999999 6 N 2010
999999999 7 Y 2010
999999999 8 Y 2010
888888888 1 N 2010
888888888 2 N 2010
888888888 3 Y 2010
CUSTOMER_ PRODUCT_CD P YEAR
888888888 4 Y 2010
888888888 5 N 2010
888888888 6 N 2010
888888888 7 Y 2010
888888888 8 Y 2010
777777777 1 Y 2010
777777777 2 Y 2010
777777777 3 Y 2010
777777777 4 Y 2010
777777777 5 Y 2010
777777777 6 Y 2010
CUSTOMER_ PRODUCT_CD P YEAR
777777777 7 Y 2010
777777777 8 Y 2010
24 rows selected.
SQL> SY.
P.S. Code assumes at least one customer ordered at least one product within each year. Otherwise you will need year table.
Edited by: Solomon Yakobson on Oct 28, 2011 2:36 PM -
Hi,
I'm having this plan, But I'm not able to understand as to which table/view it's producing the MERGE CARTESIAN JOIN, and BUFFER SORT, is it from CM_PAY_TRANS_VW but then which column it's referring to?
Please advice
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 249 | 24 (13)| 00:00:01 |
|* 1 | HASH JOIN | | 1 | 249 | 24 (13)| 00:00:01 |
| 2 | VIEW | CM_PAY_TRANS_VW | 1 | 160 | 12 (9)| 00:00:01 |
| 3 | HASH GROUP BY | | 1 | 179 | 12 (9)| 00:00:01 |
| 4 | NESTED LOOPS OUTER | | 1 | 179 | 11 (0)| 00:00:01 |
| 5 | NESTED LOOPS | | 1 | 149 | 10 (0)| 00:00:01 |
| 6 | MERGE JOIN CARTESIAN | | 19 | 2242 | 9 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID | CI_PAY_SEG | 1 | 28 | 1 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 78 | 2 (0)| 00:00:01 |
| 9 | TABLE ACCESS BY INDEX ROWID| CI_PAY | 1 | 50 | 1 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | XT156S2 | 1 | | 1 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | XT165S1 | 3 | | 1 (0)| 00:00:01 |
| 12 | BUFFER SORT | | 30 | 1200 | 8 (0)| 00:00:01 |
|* 13 | TABLE ACCESS FULL | CI_SA_TYPE_L | 30 | 1200 | 7 (0)| 00:00:01 |
|* 14 | TABLE ACCESS BY INDEX ROWID | CI_SA | 1 | 31 | 1 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | XM199P0 | 1 | | 1 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID | CI_PAY_CAN_RSN_L | 1 | 30 | 1 (0)| 00:00:01 |
|* 17 | INDEX UNIQUE SCAN | XC557P0 | 1 | | 1 (0)| 00:00:01 |
| 18 | VIEW | CM_PAY_TNDR_TYPES_VW | 174 | 15486 | 11 (10)| 00:00:01 |
| 19 | HASH GROUP BY | | 174 | 15660 | 11 (10)| 00:00:01 |
| 20 | NESTED LOOPS OUTER | | 174 | 15660 | 10 (0)| 00:00:01 |
| 21 | NESTED LOOPS OUTER | | 160 | 10080 | 9 (0)| 00:00:01 |
| 22 | TABLE ACCESS FULL | CI_PAY_EVENT | 160 | 4640 | 7 (0)| 00:00:01 |
| 23 | TABLE ACCESS BY INDEX ROWID | CI_PAY_TNDR | 1 | 34 | 1 (0)| 00:00:01 |
|* 24 | INDEX RANGE SCAN | XT265S3 | 1 | | 1 (0)| 00:00:01 |
| 25 | TABLE ACCESS BY INDEX ROWID | CI_TENDER_TYPE_L | 1 | 27 | 1 (0)| 00:00:01 |
|* 26 | INDEX UNIQUE SCAN | XC583P0 | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("A"."PAY_EVENT_ID"="B"."PAY_EVENT_ID")
10 - access("P"."PAY_EVENT_ID"='010253513440')
11 - access("P"."PAY_ID"="PSEG"."PAY_ID")
13 - filter("SA_TYP"."LANGUAGE_CD"='ENG')
14 - filter("SA"."SA_TYPE_CD"="SA_TYP"."SA_TYPE_CD")
15 - access("PSEG"."SA_ID"="SA"."SA_ID")
17 - access("P"."CAN_RSN_CD"="RSN"."CAN_RSN_CD"(+) AND "RSN"."LANGUAGE_CD"(+)='ENG')
24 - access("EVT"."PAY_EVENT_ID"="TDR"."PAY_EVENT_ID"(+))
26 - access("TDR"."TENDER_TYPE_CD"="TT"."TENDER_TYPE_CD"(+) AND "TT"."LANGUAGE_CD"(+)='ENG')is it CM_PAY_TRANS_VWYou know your data model, we don't. You also haven't posted the query, so it's a bit difficult to tell but it looks to me as though it's CI_SA_TYPE_L which is responsible. FULL TABLE ACCESS with a filter rather than an access predicate.
As to why this happening, you might find this article by Jonathan Lewis sheds some light.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/ -
Expecting a cartesian join but did not get 1 (try to understand what is hap
Hello Oracle XML DB gurus,
I have successfully registered my schemas and inserted about 10,000 XML documents into the repository. Now I need to start reporting on the data that is in the documents. Following is a simplified form of my set-up.
I have a table that contain a XML_TYPE column that is schema based.
I will call the table TEST_REF it has two columns: ID number (PK) and XML_DOC which is of the foo schema.
foo schema has the following structure (foo is unbounded).
<DataSet>
<fooList>
<foo>
<val1></val1>
<val2></val2>
</foo>
<foo>
<val1></val1>
<val2></val2>
</foo>
</fooList>
</DataSet>
What I would like to do is select the XML document that I want to extract data from using the ID column. After that I wanted to be able to select all of the data values in /DataSet/fooList/foo from that document (val1 & val2).
I was able to do just that using the following query. However, I do not understand why the following query does not give me a cartesian product when I try to operate on mulitple documents. I'm actually getting exactly what I want, which are the individual data values from each document. I just need to understand what is going on. Does the table() function when used in this fashion perform a inner join for you? I hope this make sense.
select doc.id, extractvalue(Column_value,'/foo/val1') as VALUE1,
extractvalue(Column_value,'/foo/val2') as VALUE2
from test_ref doc,
table(XMLSequence(extract(doc.XML_DOC,'/DataSet/fooList/foo'))) foobar
where doc.id ='1'
------------------------ second where causes the I thought would cause a cartesian join--------------------
where doc.id in (1,2)
Sample data and results when using second where clause:
ID=1
<DataSet>
<fooList>
<foo>
<val1>2</val1>
<val2>22</val2>
</foo>
<foo>
<val1>4</val1>
<val2>44</val2>
</foo>
</fooList>
</DataSet>
ID=2
<DataSet>
<fooList>
<foo>
<val1>1</val1>
<val2>11</val2>
</foo>
<foo>
<val1>3</val1>
<val2>33</val2>
</foo>
</fooList>
</DataSet>
Results:
ID Value1 Value2
1 2 22
1 4 44
2 1 11
2 3 33
If what I'm asking does not make sense please let me know. I'm a newbe with this Oracle XML DB stuff. However, I really like what I have seen so far!
Thanks in advance
DerrickIt's a correlated join...
-
How to get Hierarchical XML File from a Database Join Query !
Hi,
How can i get a Hierarchical XML File from a Database Join Query ?
Any join query returns repeated values as below:
BD17:SQL>select d.dname, e.ename, e.sal
2 from dept d
3 natural join
4 emp e
5 /
DNAME ENAME SAL
ACCOUNTING CLARK 2450
ACCOUNTING KING 5000
ACCOUNTING MILLER 1300
RESEARCH SMITH 800
RESEARCH ADAMS 1100
RESEARCH FORD 3000
RESEARCH SCOTT 3000
RESEARCH JONES 2975
SALES ALLEN 1600
SALES BLAKE 2850
SALES MARTIN 1250
SALES JAMES 950
SALES TURNER 1500
SALES WARD 1250
14 rows selected.
We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ROWSET>
- <ROW num="1">
<DNAME>ACCOUNTING</DNAME>
<ENAME>CLARK</ENAME>
<SAL>2450</SAL>
</ROW>
- <ROW num="2">
<DNAME>ACCOUNTING</DNAME>
<ENAME>KING</ENAME>
<SAL>5000</SAL>
</ROW>
- <ROW num="3">
<DNAME>ACCOUNTING</DNAME>
<ENAME>MILLER</ENAME>
<SAL>1300</SAL>
</ROW>
- <ROW num="4">
<DNAME>RESEARCH</DNAME>
<ENAME>SMITH</ENAME>
<SAL>800</SAL>
</ROW>
- <ROW num="5">
<DNAME>RESEARCH</DNAME>
<ENAME>ADAMS</ENAME>
<SAL>1100</SAL>
</ROW>
- <ROW num="6">
<DNAME>RESEARCH</DNAME>
<ENAME>FORD</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="7">
<DNAME>RESEARCH</DNAME>
<ENAME>SCOTT</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="8">
<DNAME>RESEARCH</DNAME>
<ENAME>JONES</ENAME>
<SAL>2975</SAL>
</ROW>
- <ROW num="9">
<DNAME>SALES</DNAME>
<ENAME>ALLEN</ENAME>
<SAL>1600</SAL>
</ROW>
- <ROW num="10">
<DNAME>SALES</DNAME>
<ENAME>BLAKE</ENAME>
<SAL>2850</SAL>
</ROW>
- <ROW num="11">
<DNAME>SALES</DNAME>
<ENAME>MARTIN</ENAME>
<SAL>1250</SAL>
</ROW>
- <ROW num="12">
<DNAME>SALES</DNAME>
<ENAME>JAMES</ENAME>
<SAL>950</SAL>
</ROW>
- <ROW num="13">
<DNAME>SALES</DNAME>
<ENAME>TURNER</ENAME>
<SAL>1500</SAL>
</ROW>
- <ROW num="14">
<DNAME>SALES</DNAME>
<ENAME>WARD</ENAME>
<SAL>1250</SAL>
</ROW>
</ROWSET>
Thank you for some help.
Nelson AlbertiHi,
I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
It can be easily scheduled as a background job to grab content on a daily basis etc ...
Regards,
Steven -
Deciphering column names in a join query using jdbc
hi all....
I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
Any pointers would be most appreciated.
cheers
vivekthanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
this also puts me in a doubt whether i can use join in my case.
for eg ... .
lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
this would return me 3 rows and i can also recognize various columns with their aliases ..
but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
i guess the only soln left is to visit contact and address table separately. :( -
How can I perform this kind of range join query using DPL?
How can I perform this kind of range join query using DPL?
SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
--mark
Maybe you are looking for
-
About executing a executable program in background
Hi to all I created a report program having one variant and downloading its content in a flat file using ws_download function. When I am going to download this in background , i am not getting the result. I am fulfulling all requirement to schedule a
-
How do I darken the darkest red, green etc, in Options- Content- Colors
I am bothered by glare and adjust browser colors for high contrast on a dark background. Black is boring after a while so I trade off to dark Green or Blue or Red etc. In IE 9 through 'Internet Options' I can choose a background color and then darken
-
Commutatio​n with 6280 DAQ Card
Hello, I want to perform parameter identification of a three phase brushless DC servo motor. Basically I want to obtain mass moment of inertia, viscous damping coefficient and coulomb friction at the bearing. To do so, I plan to apply a step voltage
-
EMERGENCY: Full Screen AIR App
I have a player that I need to have run full screen. It works fine on my Windows box when I use .width = Screen.screens[0].bounds.width and the same for height, but when I go over to a mac, I have the Apple command bar perfectly visible, and it does
-
Why can I not render short 3D animations in PS anymore?
Betreff: Video Rendering Adobe PS-64 bit CC Sehr geehrte Damen und herren: Bei uns wurde PS vor einige Zeit aktualisiert. Seidem ist kein Video Export mehr möglich bzw. den export Prozess wird nich durchgeführt und kann auch nicht abgebrochen werde