I want to know which tables the oracle application is using in order to obtain the contact information for a certain customer.
So, i go to the application (html page),i put my username and password. Then, i write the account number and click on "go". Take a look at the picture:
After that, i click on the "communication" button and the contact information appears.
Take a look:
How can i know which tables are used when i click on "go" for that account number?
A friend of mine told me that TOAD was a great tool but i dont know how to use it. Is it free? What query should i use?
Can you help me? I am a little confused :/
You can use the below query to get the contact information for a Customer at Party and Party Site levels.
SELECT DISTINCT hp.party_id,
hp.party_name,
hca.cust_account_id,
hca.account_number,
party_site_id,
party_site_number,
hcp.phone_number,
NVL (hcp.email_address, hcp.url) email_or_url,
hcp.contact_point_type communication_type,
hcp.status active,
hcp.contact_point_purpose purpose
FROM apps.hz_contact_points hcp,
apps.hz_party_sites hps,
apps.hz_cust_accounts hca,
apps.hz_parties hp
WHERE hps.party_id = hca.party_id
AND hp.party_id = hca.party_id
AND hcp.contact_point_type IN ('PHONE','EMAIL')
AND hcp.owner_table_name = 'HZ_PARTIES'
AND hcp.owner_table_id = hps.party_id
AND hcp.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hp.status = 'A'
UNION
SELECT DISTINCT hp.party_id,
hp.party_name,
hca.cust_account_id,
hca.account_number,
party_site_id,
party_site_number,
hcp.phone_number,
NVL (hcp.email_address, hcp.url) email_or_url,
hcp.contact_point_type communication_type,
hcp.status active,
hcp.contact_point_purpose purpose
FROM apps.hz_contact_points hcp,
apps.hz_party_sites hps,
apps.hz_cust_accounts hca,
apps.hz_parties hp
WHERE hps.party_id = hca.party_id
AND hp.party_id = hca.party_id
AND hcp.contact_point_type IN ('PHONE','EMAIL')
AND hcp.owner_table_name = 'HZ_PARTY_SITES'
AND hcp.owner_table_id = hps.party_site_id
AND hcp.status = 'A'
AND hps.status = 'A'
AND hp.status = 'A'
AND hca.status = 'A';
Hope this is helpful.
This question was answered already in thread: Trying to know which tables are executed in the oracle external application
You would need to look in v$sqlarea or if the SQLs execute slowly enough, you will find them in v$active_session_history. To retrieve the EBS specific user and responsibility information, you can use our active session history Blitz Report.
Related
We are facing a performance issue while executing a stored procedure. It usually takes between 10-15 minutes to run, but sometimes it takes up to more than 30 minutes to execute.
We captured visualize plan execute files for the Normal run and Long run cases.
By checking the visualized plan we came to know that, one particular Insert block of code takes extra time in the long run. And by checking
"EXPLAIN PLAN FOR SQL PLAN CACHE ENTRY <plan_id> "
the table we found that the order of execution differs in the long run.
This is the block which takes extra time to run sometimes.
INSERT INTO #TMP_DATI_SALDI_LORDI_BASE (
"COD_SCENARIO","COD_PERIODO","COD_CONTO","COD_DEST1","COD_DEST2","COD_DEST3","COD_DEST4","COD_DEST5"
,"IMPORTO","COD_VALUTA","IMPORTO_VALUTA_ORIGINARIA","COD_VALUTA_ORIGINARIA","NOTE"
)
( SELECT
SCEN_P.SCENARIO
,SCEN_P.PERIOD
,ACCOUT_ADJ.ATTRIBUTO1 AS "COD_CONTO"
,DATAS_rev.COD_DEST1
,DATAS_rev.COD_DEST2
,DATAS_rev.COD_DEST3
,__typed_NString__($1, 50)
,'RPT_NON'
,SUM(
CASE WHEN INFO.INCOT = 'FOB' THEN
CASE ACCOUT_rev.ATTRIBUTO1 WHEN 'CalcInsurance' THEN
0
ELSE
DATAS_rev.IMPORTO
END
ELSE
DATAS_rev.IMPORTO
END
* (DATAS_ADJ.IMPORTO - DATAS.IMPORTO)
)
,DATAS_rev.COD_VALUTA
,SUM(
CASE WHEN INFO.INCOT = 'FOB' THEN
CASE ACCOUT_rev.ATTRIBUTO1 WHEN 'CalcInsurance' THEN
0
ELSE
DATAS_rev.IMPORTO_VALUTA_ORIGINARIA
END
ELSE
DATAS_rev.IMPORTO_VALUTA_ORIGINARIA
END
* (DATAS_ADJ.IMPORTO_VALUTA_ORIGINARIA - DATAS.IMPORTO_VALUTA_ORIGINARIA)
)
,DATAS_rev.COD_VALUTA_ORIGINARIA
,'CPM_SP_CACL_FY_E3 Parts Option ADJ'
FROM #TMP_TAGERT_SCEN_P SCEN_P
INNER JOIN #TMP_DATI_SALDI_LORDI_BASE DATAS_rev
ON DATAS_rev.COD_SCENARIO = SCEN_P.SCENARIO
AND DATAS_rev.COD_PERIODO = SCEN_P.PERIOD
AND LEFT(DATAS_rev.COD_DEST3, 1) = 'O'
INNER JOIN CONTO ACCOUT_rev
ON ACCOUT_rev.COD_CONTO = DATAS_rev.COD_CONTO
AND ACCOUT_rev.ATTRIBUTO1 IN ('CalcFOB','CalcInsurance') --FOB,Insurance(Ocean freight is Nothing by Option)
INNER JOIN #DSL DATAS
ON DATAS.COD_SCENARIO = 'LAUNCH'
AND DATAS.COD_PERIODO = 12
AND DATAS.COD_DEST1 = 'NC'
AND DATAS.COD_DEST2 = 'NC'
AND DATAS.COD_DEST3 = 'F001'
AND DATAS.COD_DEST4 = DATAS_rev.COD_DEST4
AND DATAS.COD_DEST5 = 'INP'
INNER JOIN CONTO ACCOUT
ON ACCOUT.COD_CONTO = DATAS.COD_CONTO
AND ACCOUT.ATTRIBUTO2 = 'E3'
INNER JOIN CONTO ACCOUT_ADJ
ON ACCOUT_ADJ.ATTRIBUTO3 = DATAS.COD_CONTO
AND ACCOUT_ADJ.ATTRIBUTO2 = 'HE3'
INNER JOIN #DSL DATAS_ADJ
ON LEFT(DATAS_ADJ.COD_SCENARIO,4) = LEFT(SCEN_P.SCENARIO,4)
AND DATAS_ADJ.COD_PERIODO = 12
AND DATAS_ADJ.COD_DEST1 = DATAS.COD_DEST1
AND DATAS_ADJ.COD_DEST2 = DATAS.COD_DEST2
AND DATAS_ADJ.COD_DEST3 = DATAS.COD_DEST3
AND DATAS_ADJ.COD_DEST4 = DATAS.COD_DEST4
AND DATAS_ADJ.COD_DEST5 = DATAS.COD_DEST5
AND DATAS_ADJ.COD_CONTO = ACCOUT_ADJ.COD_CONTO
LEFT OUTER JOIN #TMP_KDPWT_INCOTERMS INFO
ON INFO.P_CODE = DATAS.COD_DEST4
GROUP BY
SCEN_P.SCENARIO,SCEN_P.PERIOD,ACCOUT_ADJ.ATTRIBUTO1,DATAS_rev.COD_DEST1,DATAS_rev.COD_DEST2
,DATAS_rev.COD_DEST3, DATAS.COD_DEST4,DATAS_rev.COD_VALUTA,DATAS_rev.COD_VALUTA_ORIGINARIA,INFO.INCOT
)
I will share the order of execution details also for normal and long run case.
Could someone please help us to overcome this issue? And also we don't know how to fix the order of the join execution. Is there any way to fix the join order execution, Please guide us.
Thanks in advance
Vinothkumar
Without a lot more detailed information, there is no way to tell exactly why your INSERT statement shows this alternating runtime behaviour.
Based on my experience, such an analysis can take quite some time and there are only few people available that are capable to perform it. If you can get someone like that to look at this, make sure to understand and learn.
What I can tell from the information shared is this
using temporary tables to structure a multi-stage data flow is the wrong thing to do on SAP HANA. Instead, use table variables in SQLScript.
if you insist on using the temporary tables, make them at least column tables; this will allow to avoid a need for some internal data materialisation.
when using joins make sure that the joined columns are of the same data type. The explain plan is full of TO_INT(), TO_DECIMAL(), and other conversion functions. Those take time, memory, and make it hard for the optimiser(s) to estimate cardinalities.
as the statement uses a lot of temporary tables, the different join orders can easily result from different volumes of data that was present when the SQL was parsed, prepared and optimised. One option to avoid this is to have HANA ignore any cached plans for the statement. The documentation has the HINTS for that.
And that is about what I can say about this with the available information.
I have a query in MS Access that is linked to a searchable report which is linked to a form. Part of the report ask users to include two reasons that will be used as criteria for a query. Currently, the report (screenshot) below does not allow for users to simply enter in 1 reason. Users must enter in 2 reasons, and if the reasons are the same, users must enter in the same reason for both fields. For example, If I only have one reason (conflict of Interest),I would need to enter that reason into both reason boxes shown on the screenshot below. I would like to be able to search for one reason while also being able to leave the other reason box blank. So simply entering in Conflict of interest for one box and have it run the query. The code I have for the query is below.
SELECT C1.ConsultID, C1.Consult_No, C1.Consult_Type, C1.Intake_Date, C1.Adult_Peds, C1.Title, C1.ConsultSummary
FROM ([Intersection Query Pre-Reasons] AS C1 LEFT JOIN tblConsultReasons AS C2 ON C1.ConsultID = C2.ConsultID) LEFT JOIN tblConsultReasons AS C3 ON C2.ConsultID = C3.ConsultID
WHERE (((C2.Reason)=Forms!FrmReasonsCriteria!Reason1) And ((C2.ReasonType)="Discerned")) And (C3.Reason)=Forms!FrmReasonsCriteria!Reason2 And C3.ReasonType="Discerned";
How would you recommend I change the code in order to do this. I believe adding a length condition to the second half of the where clause may work. But am not sure what this would look like.
Screenshot of part of the searchable report that queries on reasons
It will be something like this; I haven't tested it because that requires building forms etc and I don't have the time atm:
SELECT C1.ConsultID, C1.Consult_No, C1.Consult_Type, C1.Intake_Date, C1.Adult_Peds, C1.Title, C1.ConsultSummary
FROM ([Intersection Query Pre-Reasons] AS C1
LEFT JOIN tblConsultReasons AS C2 ON C1.ConsultID = C2.ConsultID)
LEFT JOIN tblConsultReasons AS C3 ON C1.ConsultID = C3.ConsultID
WHERE
NOT (nz(Forms!FrmReasonsCriteria!Reason1,'')='' And
nz(Forms!FrmReasonsCriteria!Reason2,'')=''
)
And (
(nz(C2.Reason=Forms!FrmReasonsCriteria!Reason1,'')=''
And C2.ConsultID is null)
Or
(nz(C2.Reason=Forms!FrmReasonsCriteria!Reason1,'')<>'' And
C2.Reason=Forms!FrmReasonsCriteria!Reason1 And
C2.ReasonType="Discerned")
)
And (
(nz(C3.Reason=Forms!FrmReasonsCriteria!Reason2,'')=''
And C3.ConsultID is null)
Or
(nz(C3.Reason=Forms!FrmReasonsCriteria!Reason2,'')<>'' And
C3.Reason=Forms!FrmReasonsCriteria!Reason2 And
C3.ReasonType="Discerned")
)
It can be simplified a bit if we know the data available, and other controls/checks the search boxes may have.
I have the following SQL-code in my (SAP IdM) Application:
Select mcmskeyvalue as MKV,v1.searchvalue as STARTDATE, v2.avalue as Running_Changes_flag
from idmv_entry_simple
inner join idmv_value_basic_active v1 on mskey = mcmskey and attrname = 'Start_of_company_change'
and mcentrytype = 'MX_PERSON' and to_date(v1.searchvalue,'YYYY-MM-DD')<= sysdate+3
left join idmv_value_basic v2 on v2.mskey = mcmskey and v2.attrname = 'Running_Changes_flag'
where mcmskey not in (Select mskey from idmv_value_basic_active where attrname = 'Company_change_running_flag')
I already found the solution for the ORA-01841 problem, as it could either be a solution similar to MSSQLs try_to_date as mentioned here: How to handle to_date exceptions in a SELECT statment to ignore those rows?
or a solution where I change the code to something like this, to work soly on strings:
Select mcmskeyvalue as MKV,v1.searchvalue as STARTDATE, v2.avalue as Running_Changes_flag
from idmv_entry_simple
inner join idmv_value_basic_active v1 on mskey = mcmskey and attrname = 'Start_of_company_change'
and mcentrytype = 'MX_PERSON' and v1.searchvalue<= to_char(sysdate+3,'YYYY-MM-DD')
left join idmv_value_basic v2 on v2.mskey = mcmskey and v2.attrname = 'Running_Changes_flag'
where mcmskey not in (Select mskey from idmv_value_basic_active where attrname = 'Company_change_running_flag')
So for the actually problem I have a solution.
But now I came into discussion with my customers and teammates why the error happens at all.
Basically for all entries of idmv_value_basic_activ that comply to the requirement of "attrname = 'Start_of_company_change'" we can be sure that those are dates. In addition, if we execute the query to check all values that would be delivered, all are in a valid format.
I learned in university that the DB-Engine could decide in which order it will run individual segments of a query. So for me the most logical explanation would be that, on the development environment (where we face the problem), the section " to_date(v1.searchvalue,'YYYY-MM-DD')<= sysdate+3” is executed before the section “attrname = 'Start_of_company_change'”
Whereas on the productive environment, where everything works like a charm, the segments are executed in the order that is descripted by the SQL Statement.
Now my Question is:
First: do I remember that right, since the teacher said that only once and at that time I could not really make sense out of it
And Second: Is this assumption of mine correct or is there another reason for the problem?
Borderinformation:
The Tool uses a kind of shifted data structure which is why there can be quite a few different types in the actual “Searchvalue” column of the idmv_value_basic_activ view. The datatype on the database layer is always a varchar one.
"the DB-Engine could decide in which order it will run individual segments of a query"
This is correct. A SQL query is just a description of the data you want and where it's stored. Oracle will calculate an execution plan to retrieve that data as best it can. That plan will vary based on any number of factors, like the number of actual rows in the table and the presence of indexes, so it will vary from environment to environment.
So it sounds like you have an invalid date somewhere in your table, so to_date raises an exception. You can use validate_conversion to find it.
I've got a piece of code here that should be working but is not, and for the life of me I have no idea why or a better way to go about it.
What I am trying to achieve is having B1 print and delivery determine who the current user is when emailing an A/R invoice, if its X user then it will send the email directly, if it's any other user then it will save as draft + preview. Below is my current code.
DECLARE #GetUser AS nvarchar(12)
SET #GetUser = (Select top 1 T1.U_NAME from USR5 T0 INNER JOIN OUSR T1 ON T0.UserCode = T1.USER_CODE where SessionID =##spid order by Date desc,Time desc)
IF(#GetUser = 'NickJ')
BEGIN
SELECT 'noDraft' FOR BROWSE
END
ELSE
BEGIN
SELECT 'draft' FOR BROWSE
END
When I run that select statement in SAP B1 query generator it shows me NickJ, so I know it works. However boyum and print and delivery seem to not like this query. When I click the email button its not detecting that NickJ is the current user and will instead do the ELSE action.
I also noticed that $[USERNAME] won't work in this conditional or report action.
Does anyone know of a better way of getting the current logged in user for this?
Just base everything of a SQL Query with a CASE selection like below.
Do not use Procedure...do not use C# or VB script. Use only the DocKey# Parameter coz thats the most common parameter used in most layouts. Just my observation to get it work. Bit late but posting for future reference. Hope ur issue is resolved by now.
This syntax is B1 HANA
Select case OINV."DocType" when 'I' then 'Items' else 'Service' end DocType
from OINV where OINV."DocEntry" = DocKey#
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