How to join ChargeBacks with original transaction invoice in Oracle AR query? - oracle

I want to join chargeback transaction to its original invoice but I cannot find a link to join in table.
Both transactions exist independently in table : ar_payment_schedules_all
I need to find a join like some transaction_id etc.

They join through the AR_ADJUSTMENTS_ALL table.
Join:
AR_PAYMENT_SCHEDULES_ALL.CUSTOMER_TRX_ID = AR_ADJUSTMENTS.CHARGEBACK_CUSTOMER_TRX_ID.
... to get the adjustment record(s) that associate the chargeback with the original transaction(s). Then join:
AR_ADJUSTMENTS.PAYMENT_SCHEDULE_ID = AR_PAYMENT_SCHEDULES_ALL.PAYMENT_SCHEDULE_ID
... to get the payment schedule(s) of the original transaction(s).
See the DDL for the seeded view AR_CHARGEBACKS_V for code.

Related

JOIN 4 tables in one (Oracle R11)

I need to create a query that shows the "Legal Entity", "Application Name", "Close Date" and "Period" I'm working with Oracle R11, Right now I've found the query for
"Legal Entity"
SELECT name
FROM hr_organization_information HOI
INNER JOIN hr_all_organization_units HAOU
ON HOI.ORGANIZATION_ID = Haou.Organization_Id
WHERE HOI.org_information_context LIKE 'Legal Entity Accounting'
ORDER BY NAME ASC;
and for "Application Name, Close Date, Period"
SELECT A.APPLICATION_ID,
B.APPLICATION_NAME,
TO_CHAR(A.END_DATE,'HH24:MI DD-MON-YYYYI'),
A.PERIOD_NUM
FROM GL_PERIOD_STATUSES A
INNER JOIN FND_APPLICATION_TL B ON A.APPLICATION_ID = B.APPLICATION_ID
WHERE A.Application_Id=101
AND LANGUAGE='US'
OR A.APPLICATION_ID=200
AND LANGUAGE='US'
OR A.APPLICATION_ID=222
AND LANGUAGE='US';
Separately but I haven't found the way to join them in one query, can you help me with that?
Antonio, I think Brian has given you sound advice. Posting to an EBS forum (or whatever application this is) might also be worthwhile if his advice has not lead you to the answer. I will offer that sometimes the way to join table_A and table_B is through table_C. That is, if you do not find any directly related data in the queries of one se to one of the tables in the other set then look at the FK defined on and pointing to these tables to see if you can find a table not currently part of either query that relates the sets. You figure out how to join each of your current queries to it and that is how you join the two queries together.
Thank you all!
The advices that all of you gave to me were useful, I've found the table HR_LEGAL_ENTITIES (Table C) that have two columns that allow me to join Table A with Table B, the final query was:
SELECT HAOU.NAME,
FAT.APPLICATION_NAME,
TO_CHAR(GPS.END_DATE,'HH24:MI DD-MON-YYYY'),
GPS.PERIOD_NUM
FROM HR_ALL_ORGANIZATION_UNITS HAOU
INNER JOIN HR_LEGAL_ENTITIES HLE
ON HLE.ORGANIZATION_ID = HAOU.ORGANIZATION_ID
INNER JOIN GL_PERIOD_STATUSES GPS
ON HLE.SET_OF_BOOKS_ID = GPS.SET_OF_BOOKS_ID
INNER JOIN FND_APPLICATION_TL FAT
ON GPS.APPLICATION_ID = FAT.APPLICATION_ID
WHERE GPS.Application_Id IN (101,200,222) AND LANGUAGE='US'
ORDER BY NAME ASC;
Regards!

Joining multiple table in oracle 11g using sql query

i want all the column of treat_info table and corresponding fee of treatment table and equipment table.what is the sql query ?
The 3 tables image link is below
https://drive.google.com/file/d/0B3BFGC_k79UObHRjMGZpVXZwa3M/view?usp=sharing
I decided to use "LEFT JOIN" for not be sure if the fields are TREATMENT and EQUIPMENT are foreign keys.
So, you have the FEE value, if they exist.
select
T1.*
,T2.FEE as TREATMENT_FEE
,T3.FEE as EQUIP_FEE
from TREAT_INFO as T1
left join TREATMENT as T2 on T2.TREATMENT = T1.TREATMENT
left join EQUIPMENT as T3 on T3.EQUIPMENT = T1.EQUIPMENT

checking values from two tables?

I had two tables
table1 contains a list of customer and their info and there is a customer id for each one
table2 contains a list of request from all with and customer id for each request as foreign key
and i want to check the customer who has request and who is not
plz how should that be done logical is it possible to eqaul between two queries ?
thanks
You have two tables, the first with one row per customer, the other with zero to many rows per customer. So you need two techniques: one to reduce the second table to one row per customer and the other to join that result set to the first table. These techniques are an aggregating sub-query and an outer join respectively.
select c.customer_id
, nvl(r.req_count, 0) as no_of_reqs
from customer c
left outer join ( select customer_id
, count(*) as req_count
from customer_req
group by customer_id ) r
on c.customer_id = r.customer_id

ORA-017779 : cannot modify a column which maps to non key-preserved table

How can I solve this error:
ORA-017779 : cannot modify a column which maps to non key-preserved table.
My Code:
UPDATE (SELECT SOBS034.T1 as OLD, SOBS063.T1 as NEW
FROM SOBS034
INNER JOIN SOBS063 ON SOBS034.ID = SOBS063.ID
where SOBS034.ID='111000' AND SOBS063.T2='' ) t
SET t.OLD =t.NEW
To update a JOIN, Oracle needs to be absolutely sure that for each row of the table you are trying to update, there will be at most one row of the joined table.
Here you'll be able to update the join if and only if SOBS063.ID is unique (explicitely declared by a unique constraint/pk).
If somehow SOBS063.ID is unique for this record with your join condition but is not declared as such, you won't be able to use this method. You could however transform this DML into an equivalent MERGE, something like this:
MERGE INTO SOBS034 a
USING SOBS063 b
ON (a.id = b.id AND a.ID='111000' AND b.T2 IS NULL)
WHEN MATCHED THEN UPDATE SET a.t1 = b.t1;
By the way SOBS063.T2='' is never true in Oracle right now.
Try to create a unique index on SOBS034 (ID) and SOBS063 (ID).

Entity Framework 4 generated queries are joining full tables

I have two entities: Master and Details.
When I query them, the resulting query to database is:
SELECT [Extent2]."needed columns listed here", [Extent1]."needed columns listed here"
FROM (SELECT * [Details]."all columns listed here"...
FROM [dbo].[Details] AS [Details]) AS [Extent1]
LEFT OUTER JOIN [dbo].[Master] AS [Extent2] ON [Extent1].[key] = [Extent2].[key]
WHERE [Extent1].[filterColumn] = #p__linq__0
My question is: why not the filter is in the inner query? How can I get this query? I've tried a lot of EF and Linq expressions.
What I need is something like:
SELECT <anything needed>
FROM Master LEFT JOIN Details ON Master.key = Details.Key
WHERE filterColumn = #param
I'm having a full sequential scan in both tables, and in my production environment, I have milions of rows in each table.
Thanks a lot !!
Sometimes The entity Framework does not produce the best query. You can do a few of the following to optimize.
Modify the linq statement (test with
LINQPad)
Create a stored proc and map the stored proc to return an entity
Create a view that handles the join and map the view to a new
entity

Resources