Need to know backend location(table name) of Customer Ship To Number in Oracle EBS - sql

I am working in Oracle E-Business Suite.
Considering this field "CUSTOMER_SHIP_TO_NUMBER"
Oracle EBS Screenshot
I need to know the column and the table in the back-end database, from which the values of this field is getting populated.
I tried examining the Record History, and the data is being fetched from a View, namely the OE_Order_Lines_V. I tried searching through that view but couldn't figure it out. I need to know the actual location, namely the Table, where this data (CUSTOMER_SHIP_TO_NUMBER) is being stored.

You can use the below query to find the customer details.
SELECT hp.party_name "CUSTOMER_NAME",
hca.account_number "CUSTOMER_NUMBER",
csu.location "SHIP_TO_ORG_ID",hca.cust_account_id "CUSTOMER_ID"
FROM hz_parties hp, hz_cust_accounts hca,
hz_cust_acct_sites_all cas, hz_cust_site_uses_all csu
WHERE hp.party_id = hca.party_id
AND hca.party_site_id = cas.party_site_id
AND cas.cust_acct_site_id = csu.cust_acct_site_id
AND cas.address_type = 'SHIP_TO'
AND csu.location = <ship_to_org_id>;

The Data comes from the Table ONT.OE_ORDER_LINES_ALL, under the column of END_CUSTOMER_ID.
This should be joined with AR.RA_CUSTOMERS using the column CUSTOMER_ID to get the Customer Name and Number:
SELECT racust.customer_id
, racust.customer_name
, racust.customer_number -- this is the SHIP_TO_CUSTOMER_NUMBER
FROM AR.RA_CUSTOMERS racust
, ONT.OE_ORDER_headers_all oola
where oola.END_CUSTOMER_ID = racust.CUSTOMER_ID;
Read More Here: Oracle Order Management Technical Reference Manual

Related

Joining SQL statements Atrium Syntess Firebird DB

I'm trying to get (one or multiple) number lines (PROGCODE) that are attached to an OBJECT (i.e. a building) that is connected to a Relation which in turn has a GC_ID (relation unique ID). I need all the buildings & progcodes connected to a relation ID in a firebird 2.5 database generated by my companies ERP system.
I can look through all the tables in the firebird database and run select queries on them.I like to think I have the join statement syntax down and I know how to find the unique ID belonging to a relation, unfortunately I'm unsure how I can find the correct table that houses the information I seek.
The table I think this data is in has the following fields:
GC_ID, DEVICE_GC_ID, USER_GC_ID, CODE, DESCRIPTION.
However when I query it using
select GC_ID, DEVICE_GC_ID, USER_GC_ID, CODE, DESCRIPTION
from AT_PROGCODE A
Then I get a description of the fields I'm trying to query.
i.e.
| GC_ ID : 100005 | DEVICE_GC_ID : 100174 | USER_GC_ID : 1000073 | DESCRIPTION: >description of what I'm trying to query< |
Can anyone shed some insight how I should handle this?
Update 7-09-2017
I spoke with the ERP consultant and was told the tables I needed (if anyone reading this is using syntess Atrium; the AT_BRENT table holds a description of all the tables.)
However, I've run into a new problem; the data I get from my sql query keeps streaming (it seems to never end with me stopping the script at 90 mil loops and the ERP program crashing if I ask for a count).
select A.GC_OMSCHRIJVING Bedrijf, A.GC_CODE ,M.GC_OMSCHRIJVING Werktitel,
M.TELEFOON1, M.TELEFOON2, M.MOBIEL, M.EMAIL,
M.URL, M.DOORKIES_NR, M.WERKLOCATIE, M.EMAIL_INTERN
from AT_MEDEW M , AT_RELATIE A
JOIN AT_MEDEW ON A.GC_ID = M.GC_ID
WHERE M.TELEFOON1 <> '' OR M.TELEFOON2 <> '' OR M.MOBIEL <> ''
Any ideas on what's the cause for my latest peril?
First I had to find the AT_BRENT table which holds all the descriptions for tables in Syntess Atrium
Then I was using a CROSS JOIN (as pointed out by https://stackoverflow.com/users/696808/bacon-bits )
I ended up using
select A.GC_OMSCHRIJVING Bedrijf, A.GC_CODE ,M.GC_OMSCHRIJVING Werktitel,
M.TELEFOON1, M.TELEFOON2, M.MOBIEL, M.EMAIL,
M.URL, M.DOORKIES_NR, M.WERKLOCATIE, M.EMAIL_INTERN
from AT_MEDEW M
JOIN AT_RELATIE A ON A.GC_ID = M.GC_ID
WHERE M.TELEFOON1 <> '' OR M.TELEFOON2 <> '' OR M.MOBIEL <> ''
Thank you all who helped.

Type conversion failure in update query

I'm fairly new to Access so this is driving me a little crazy.
I'm creating an inventory database and want to count the number of items in stock to update an ordering form. Received items are assigned an order code, and I want to count the number of instances of each order code found within the master table. I have a make table query which does this just fine:
SELECT PrimerList.PrimerName
, First(Primer_Master.FR) AS FR
, Primer_Master.OrderCode
, Count(Primer_Master.OrderCode) AS InStock
INTO PrimerOrder
FROM PrimerList
LEFT JOIN Primer_Master ON PrimerList.ID = Primer_Master.PrimerName
GROUP BY PrimerList.PrimerName
, Primer_Master.OrderCode
, Primer_Master.PrimerName
, Primer_Master.FR
, Primer_Master.Finished
HAVING ((([Primer_Master]![Finished])=No));
I want to use PrimerOrder to update an order list table PrimerOrderList which has all of the different possible order codes, updating the InStock value for records with matching OrderCode:
UPDATE PrimerOrderList
SET PrimerOrderList.InStock = PrimerOrder.InStock
WHERE (((PrimerOrderList.OrderCode)=[PrimerOrder].[OrderCode]));
However, when I try to run it I get parameter boxes which pop-up asking for PrimerOrder.OrderCode and PrimerOrderList.OrderCode. Even if I put in a valid value for each, I get a type conversion failure. I've checked the data types for both tables and don't see how there could be a type conversion failure - both are set to text.
Any insight would be greatly appreciated! Thanks in advance!
You haven't included the PrimerOrder table in your query. Should be:
UPDATE PrimerOrderList INNER JOIN PrimerOrder
ON PrimerOrderList.OrderCode = PrimerOrder.OrderCode
PrimerOrderList.InStock = PrimerOrder.InStock

SQL - Getting a column from another table to join this query

I've got the code below which displays the location_id and total number of antisocial crimes but I would like to get the location_name from a different table called location_dim be output as well. I tried to find a way to UNION it but couldn't get it to work. Any ideas?
SELECT fk5_location_id , COUNT(fk3_crime_id) as TOTAL_ANTISOCIAL_CRIMES
from CRIME_FACT
WHERE fk1_time_id = 3 AND fk3_crime_id = 1
GROUP BY fk5_location_id;
You want to use join to lookup the location name. The query would probably look like this:
SELECT ld.location_name, COUNT(cf.fk3_crime_id) as TOTAL_ANTISOCIAL_CRIMES
from CRIME_FACT cf join
LOCATION_DIM ld
on cf.fk5_location_id = ld.location_id
WHERE cf.fk1_time_id = 3 AND cf.fk3_crime_id = 1
GROUP BY ld.location_name;
You need to put in the right column names for ld.location_name and ld.location_id.
you need to find a relationship between the two tables to link a location to crime. that way you could use a "join" and select the fields from each table you are interested in.
I suggest taking a step back and reading up on the fundamentals of relational databases. There are many good books out there which is the perfect place to start.

Need to pull only last date in table that stores change dates SQL / ODBC

Hope somebody can help me with this. I'm trying to pull a list of forthcoming titles (I work in publishing) via ODBC/ms query. I want (amongst other things) to show their internal status (approved, prepress etc.). The database stores the change dates for the status'. I seem to be getting one line per status per title. So if the title has changed status 6 times, I will get 6 lines. But I only want to show the latest status...
The date is in BL_PROJECT_TO_STATUS.STATUS_DATE (I've inserted a date criteria beneath, just to make it more visible).
How can this be done? I'm very new to ODBC and would appreciate it a lot.
SELECT DISTINCT
BL_PROJECT.EXP_PUB_DATE, BL_PROJECT.EAN, BL_PROJECT.TITEL,
MEDIATYPE.DESCRIPTION, BL_PROJECT_STATUS.DESCRIPTION
FROM
FIRMA1.BL_PROJECT BL_PROJECT, FIRMA1.BL_PROJECT_STATUS BL_PROJECT_STATUS,
FIRMA1.BL_PROJECT_TO_STATUS BL_PROJECT_TO_STATUS, FIRMA1.MEDIATYPE MEDIATYPE
WHERE
BL_PROJECT.PROJECT_ID = BL_PROJECT_TO_STATUS.PROJECT_ID AND
BL_PROJECT_TO_STATUS.STATUS_ID = BL_PROJECT_STATUS.CODE AND
BL_PROJECT.MEDIATYPE = MEDIATYPE.ID AND
((BL_PROJECT.PROJECT_TYPE = 2) AND
(BL_PROJECT.EXP_PUB_DATE Between SYSDATE AND (SYSDATE+90)) AND
(BL_PROJECT_TO_STATUS.STATUS_DATE = {ts '2013-11-20 00:00:00'}))
ORDER BY
BL_PROJECT.EXP_PUB_DATE, BL_PROJECT.EAN, BL_PROJECT.TITEL
Here is the general idea. You can adapt it with your table and field names.
select somefields
from sometables
join
(select something, max(datetimefield) maxdt
from table1
where whatever
group by something ) temp on table1.datetimefield = maxdt
etc

running queries on more than one table

I'm trying to make a query in two tables:
SIMPLE_PERSON with 3 fields (name, grid and Social Security Card)
INDIVIDUAL_AGGREGATE with 4 fields: grid(PK), type( D(Driver) or C(client)), code, simple_person(foreign key of simple_person))
When I register some person, I have to save they on the SIMPLE_PERSON and set the type of aggregate that they are ( Driver or Client). And cannot have two equal social security card numbers.
With AJAX, I throw a checker that returns an alert box if the SSC is registered, but my SQL query doesn't work. I need to making a query that returns to me if a Social Security Card is already registered. I'm trying to use EXISTS, but I haven't had much success:
SELECT simple_person.name
FROM simple_person
WHERE SSC = 'SSC_NUMBER'
AND EXISTS (SELECT individual_aggregate.code FROM individual_aggregate
WHERE code = 'xx'
AND individual_aggregate.type = 'D');
Somebody can help me to make this query work?
did you wanted to check if there is a person that registered on a some Social security number?
if yes what i did is join between the two tables
and return the rows that equal to a specific social security number.
you can add to the WHERE statement (AND IA.code = 'XX' AND IA.Type = 'D')
SELECT SP.Name
FROM simple_person AS SP
INNER JOIN individual_aggregate AS IA ON SP.grid = IA.grid
WHERE SP.SSC = {someNumber}
helped you?
Your subquery in the EXISTS clause isn't actually hitting a table, view or other.
Your sub-select is missing the FROM clause.
SELECT
individual_aggregate.code
FROM
individual_aggregate
WHERE
code = 'xx'
AND individual_aggregate.type = 'D'
Regards
Sigersted