[JPA] How to avoid excessive joins in queries on InheritanceType.JOINED
Hi,
Let me use an over-simplified example to illustrate my question:
Let's assume I have two classes: SuperClass and SubClass. As the name suggests, SubClass extends SuperClass.
I have mapped them in JPA via:
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="CTYPE", discriminatorType=DiscriminatorType.INTEGER)
@PrimaryKeyJoinColumn(name="ID")And now let's suppose I run the following query:
Query q = entityManager.createQuery("select o.id from SubClass o");In this case, TopLink Essentials generates SQL with a join between the base table and the detail table. Why? All I need is the ID which is available in the detail table too. The base table doesn't need to be included in the query.
Is there a way to avoid the unnecessary join? I even tried mapping the ID column in both entities but it didn't help.
Best regards,
Bisser
Thank you for you reply, Doug!
I don't want to instantiate SubClass. I only wish to get the ID. I don't need validations or fields from the superclass.
Should I resort to using native SQL for that?
(By the way, the real query that I use in my program instantiates a completely different entity. I use the SubClass in a subquery. And I don't need the SuperClass to get involved. I have a foreign key that guarantees that the SuperClass's row exists in the database.)
Best regards,
Bisser
Similar Messages
-
How to avoid cartesion join is there any alternate way
Hi,
I have table
1.sitemaster
2.Invmaster
Sitemaster will have some hundrer sites and Invmaster will have thousands of items or product
I have an Situation for each site i need to show all product so iam linking with cartetion join but its taking more time
is there any other alternate way to get same result as cartetion join . Please can any one guide me?Hi iam saying i need a result like cartesion join only
Table invmaster
INVIID
SKU
UPC
DESCRIPTION
DATEADDED
MAINGROUP
AVAILGROUP
REPORTGROUP
COMMGROUP
TAXGROUP
EXCHANGEGROUP
ATTRGROUP
METERGROUP
MANUFACTURER
MANPARTNUM
MODEL
ACTIVE
MADEIN
QTYSERIAL
SELLPRICE
COST
LOWESTSELLPRICE
REPLACEMENTCOST
ALLOWDISCOUT
DAMAGEWAIVER
ALLOWSUBRENT
ALLOWCONSIGNED
SHELFLOCATION
BINNUMBER
PACKAGE
TYPE
DEPOSITTYPE
DEPOSITVALUE
AFFECTSAVAILABILITY
URL
UCDESCRIPTION
PRINTONORDER
ISMISCITEM
LENGTH
WIDTH
HEIGHT
WEIGHT
BOOKDEPRECIATIONIID
TAXDEPRECIATIONIID );
Sitemaster
SITEIID
SITEID
SITENAME
ADDRESSIID
GMT
PARENTIID
PARENTSERVER
REGION
DISTRICT
CLASS
SITEPRICEGROUP
PHONE
FAX
DAYSINWEEK
TIMEZONE
SHIPDATEOFFSET
PHYSICALCOUNTSTART
LOCALE
GEOGRAPHICALREGION
CATEGORYGROUPIID
RETURNDATEOFFSET
MASTERBILLSHARINGTYPE
MASTERBILLSHARING
SERVICECHARGETYPE
SERVICECHARGEVALUE
SCONDISCOUNTEDAMOUNT
SERVICECHARGEONSELLITEMS );
I have created view such that linking othere table with columns index,
but only in sitemaster i made cartetion join but my result is as expected but its taking more time below is my
plan please can you suggest is there any alternate way?
Execution Plan
Plan hash value: 4005734062
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 11822 | 24 (9)| 00:00:01 |
| 1 | VIEW | ALLITEMVIEW | 2 | 11822 | 24 (9)| 00:00:01 |
| 2 | UNION-ALL | | | | | |
| 3 | NESTED LOOPS OUTER | | 1 | 164 | 2 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID | INVMASTER | 1 | 149 | 2 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | IDX_INVMASTERSKU | 1 | | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | INVSUBCATEGORY | 2 | 30 | 0 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | PK_INVSUBCATEGORYIID | 1 | | 0 (0)| 00:00:01 |
|* 8 | HASH JOIN OUTER | | 1 | 1886 | 22 (10)| 00:00:01 |
| 9 | NESTED LOOPS OUTER | | 1 | 1873 | 19 (0)| 00:00:01 |
| 10 | NESTED LOOPS OUTER | | 1 | 818 | 17 (0)| 00:00:01 |
| 11 | VIEW | SITEITEMVIEW | 1 | 676 | 17 (0)| 00:00:01 |
|* 12 | FILTER | | | | | |
| 13 | NESTED LOOPS | | 11 | 2827 | 17 (0)| 00:00:01 |
| 14 | NESTED LOOPS OUTER | | 1 | 226 | 2 (0)| 00:00:01 |
|* 15 | TABLE ACCESS BY INDEX ROWID| INVMASTER | 1 | 214 | 2 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | IDX_INVMASTERSKU | 1 | | 1 (0)| 00:00:01 |
| 17 | TABLE ACCESS BY INDEX ROWID| INVSUBCATEGORY | 2 | 24 | 0 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | PK_INVSUBCATEGORYIID | 1 | | 0 (0)| 00:00:01 |
| 19 | TABLE ACCESS FULL | SITEMASTER | 11 | 341 | 15 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | IDX_COMSITEAUTHORIZEDPRODUCTS | 1 | 13 | 0 (0)| 00:00:01 |
|* 21 | INDEX UNIQUE SCAN | IDX_COMSITEAUTHORIZEDPRODUCTS | 1 | 26 | 0 (0)| 00:00:01 |
| 22 | TABLE ACCESS BY INDEX ROWID | IMAGEFILEREFERENCE | 1 | 142 | 0 (0)| 00:00:01 |
|* 23 | INDEX RANGE SCAN | IDX_IMAGEFRPARENTIID | 1 | | 0 (0)| 00:00:01 |
| 24 | VIEW PUSHED PREDICATE | INVITEMVIEW | 1 | 1055 | 2 (0)| 00:00:01 |
| 25 | NESTED LOOPS | | 1 | 45 | 2 (0)| 00:00:01 |
| 26 | NESTED LOOPS | | 1 | 30 | 1 (0)| 00:00:01 |
|* 27 | INDEX UNIQUE SCAN | PK_SITEMASTER | 1 | 10 | 0 (0)| 00:00:01 |
| 28 | TABLE ACCESS BY INDEX ROWID | INVNONSERIAL | 1 | 20 | 1 (0)| 00:00:01 |
|* 29 | INDEX UNIQUE SCAN | IDX_INVNONSERIALSITEIIDINVIID | 1 | | 0 (0)| 00:00:01 |
|* 30 | TABLE ACCESS BY INDEX ROWID | INVMASTER | 1 | 15 | 1 (0)| 00:00:01 |
|* 31 | INDEX UNIQUE SCAN | PK_INVMASTER | 1 | | 0 (0)| 00:00:01 |
| 32 | VIEW | | 6 | 78 | 2 (50)| 00:00:01 |
| 33 | HASH UNIQUE | | 6 | 30 | 2 (50)| 00:00:01 |
| 34 | INDEX FULL SCAN | PK_SUGGESTEDITEMS | 21 | 105 | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------------------------- -
Hi
Assume I have following table
Id Code
1 aa
1 bb
1 cc
2 bb
2 cc
The records will be grouped by Id. I want to find out group containing code say 'aa' and 'bb'.
Is it possible to obtain the desired result in a single query without using Self join?
Regards
~PravinThis is a little clumsy....Anyway try it:
WITH t AS
(SELECT 1 id,'aa' code FROM dual
UNION ALL
SELECT 1,'bb' FROM dual
UNION ALL
SELECT 1,'cc' FROM dual
UNION ALL
SELECT 2,'bb' FROM dual
UNION ALL
SELECT 2,'cc' FROM dual)
SELECT id FROM t
WHERE code IN('aa', 'bb')
GROUP BY id HAVING COUNT(*) = 2; -
How to avoid Cartesian join in sqlquery
Please ignore this Thread.
Thanks
Lax
Edited by: LAX_ORA on 05-Nov-2012 08:23It is always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details. -
How to avoid duplicates in CROSS JOIN Query
Hi,
I am using CROSS JOIN to get all the subset of a table col values as shown below:
PRODUCT (Col Header)
Bag
Plate
Biscuit
While doing cross join we will get as
Bag Bag
Bag Plate
Bag Biscuit
Plate Bag
Plate Plate
Plate Biscuit ..... like this
By placing where condition prod1 <> prod2 to avoid Bag Bag and Plate Plate values. So the output will be like below
Bag Plate
Bag Biscuit
Plate Bag
Plate Biscuit
Now "Bag Plate" and "Plage Bag" are same combination how to avoid these records. My expected result is
Bag Biscuit
Plate Biscuit
How to derive this ?
SridharHi,
This is the the solution that I found as fit to the OP question, but
Visakh16 already posted the same idea (assuming the names are unique) from the start and I don't think that anyone notice it!
Sridhar.DPM did
you check Visakh16's response
(the second response received)?!?
I will mark his response as an answer. If this is not what you need pls clarify and you can unmark it :-)
[Personal Site] [Blog] [Facebook] -
How to avoid Duplicate Records while joining two tables
Hi,
I am trying to join three tables, basically two tables are same one is like history table, so I wrote a query like
select
e.id,
e.seqNo,
e.name,
d.resDate,
d.details
from employees e,
((select * from dept)union(select * from dept_hist)) d
join on d.id=e.id and e.seqno=d.seqno
but this returing duplicate records.
Could anyone please tell me how to avoid duplicate records of this query.Actually it is like if the record is processed it will be moved to hist table, so both table will not have same records and I need the record from both the tables so i have done the union of both the tables, so d will have the union of both records.
But I am getting duplicate records if even I am distinct. -
How to avoid the message in the dashboard report
Hi,
I am developing Dashboard reports(graphs) using WAD. Query and WAD are working fine. I need to put a variable for Calendar Month or Year in the graph .I am populating the Variable with default value initially and I am getting the correct result . But if I change the Variable value second time, I am getting a message (type I(information) ) in the same screen which says that 'You cannot change variable ZCALYEAR_WT01 for charact. 0CALYEAR during query navigation' . And below is the detailed information about the error message.
The Can be changed in query navigation property has been set for variable ZCALYEAR_WT01, characteristic 0CALYEAR. However, the variable is used in the query in such a way, that the system is unable to apply this change-option.
This can, for example, occur under the following conditions:
Characteristic 0CALYEAR is filtered by additional restrictions (the restrictions must be joined using an OR-connection)
A second characteristic, which is restricted by a variable, is compounded to charcteristic 0CALYEAR.
Variable ZCALYEAR_WT01 is a hierarchy node variable, but the hierarchy has not been determined uniquely.
A variable can be changed during query navigation only if it is used exclusively in a drilldown-characteristic, and there are no further restrictions to the characteristic other than this variable. There must be no additional characteristics with variables compounded to the characteristic you are working with. For variables for hierarchy nodes, the hierarchy must be determined uniquely and agree with the set display hierarchy.
Also, if the characteristic value is moved, for example (ZCALYEAR_WT01 - 1), the variable is no longer able to be changed when navigating queries.
System Response
The entry ZCALYEAR_WT01 Can be changed during query navigation is not applied.
Procedure
I checked the query definition and it is not having any offset or any other restrictions for Calendar Year
It is used for finding the total quantity by country for the year .Hence Quantity keyfigure is added in the Keyfigures and Country is in the Rows and Calendar Year is restricted with Variable in the global filter .There are no other fields and no other restrictions .
I am still trying to figure out why the warning apprears in the DashBoard. Since this Dashboard report will be used by the Power users and this warning message will be annoying to them .Hence I need to find how to avoid this message.
Kindly do let me if anyone has faced this and solved earlier.
Thanks for your time.
Thanks & Regards,
RajaHi Nick,
Thanks for your suggestion and it worked for me I added the 'System message' web item and set the visibility to 'Hidden' .Now I am not getting any message. Thank you for both.
Thanks & Regards,
Raja -
Please reply:how to avoid extra trailing spaces while using cursor sharing
i am using cursor sharing with FORCE or SIMILAR.
what is the solution to avoid extra trailing spaces without any java code change.
do we have any option in oracle to avoid extra trailing spaces during the query processing ?
I am using Oracle 10g
CURSOR SHARING is a feature in which multiple sql statements
which are same will have a shared cursor (in the library cache) for an oracle session,
i.e, the first three steps of the sql processing (hard parse, soft parse, optimization)
will be done only the first time that kind of statement is executed.
There are two ways in which similar SQL statements with different condition values can be made to "SHARE" cursor during execution:
1. Writing SQLs with Bind Variables: SQLs having no hard coded literals in them
For e.g., the query below
SELECT node.emp_name AS configid
FROM emp node
WHERE emp_no = :1
AND dept_no =
DECODE (SUBSTR (:2, 1, 3),
:3, :4,
(SELECT MAX (dept_no)
FROM emp
WHERE emp_no = :5 AND dept_no <= :6)
AND node.dept_type = :7
ORDER BY node.emp_name
Here all the variables are dynamically bound during the execution. The ":X" represents BIND Variable and the actual values are bound to the SQL only at the 4th step of the execution of the SQL.
In applications: The queries written with "?" as bind variables will be converted into ":X" and are sqls with Bind Variables.
2. The CURSOR_SHARING parameter: Only Useful for SQL statements containing literals:
For eg., the query below:
SELECT node.emp_name AS configid
FROM emp node
WHERE emp_no = 'H200'
AND dept_no =
DECODE (SUBSTR (:1, 1, 3),
'PLN', :2,
(SELECT MAX (dept_no)
FROM emp
WHERE emp_no = :3 AND dept_no <= :4)
AND node.dept_type = :5
ORDER BY node.emp_name
In the query above, there are two hard coded literals H200 , PLN. In this case when the same SQL executed with different values like (H2003 , PLN), oracle will create a new cursor for this statement and all the first three steps ( hard & soft parse and optimization plan) needs to be done again.
This can be avoided by changing the CURSOR_SHARING parameter which can be set to any of three values:
1. EXACT: Causes the mechanism not be used, i.e. no cursor sharing for statements with different literals. This is the default value.
2. FORCE: Causes unconditional sharing of SQL statements that only differ in literals.
3. SIMILAR: Causes cursor sharing to take place when this is known not to have any impact on optimization.
So, FORCE and SIMILAR values of the parameter will be helping in cursor sharing and improve the performance of the SQLs having literals.
But here the problem arises if we use the FORCE and SIMILAR other than EXACT.
alter session set cursor_sharing ='EXACT'
select 1 from dual;
'1'
1
alter session set curson_sharing='FORCE'
select 2 from dual;
'2'
2
alter session set curson_sharing='SIMILAR'
select 3 from dual;
'3'
3
So, this will give extra trailing spaces in when we retrieve from java method and any
further java processing based on the hardcoded literal values will fail. this needs lot of
effort in remodifying the existing millions of lines of code.
My question is i have to use cursor sharing with FORCE or SIMILAR and can't we do the trimming
from the oracle query processing level ?
please help me on this ?
Message was edited by:
Leeladhar
Message was edited by:
LeeladharPlease reply to this thread
How to avoid extr trailing spaces using Cursor sharing opton FORCE, SIMILAR -
How to avoid performance problems in PL/SQL?
How to avoid performance problems in PL/SQL?
As per my knowledge, below some points to avoid performance proble in PL/SQL.
Is there other point to avoid performance problems?
1. Use FORALL instead of FOR, and use BULK COLLECT to avoid looping many times.
2. EXECUTE IMMEDIATE is faster than DBMS_SQL
3. Use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy of OUT is avoided.Susil Kumar Nagarajan wrote:
1. Group no of functions or procedures into a PACKAGEPutting related functions and procedures into packages is useful from a code organization standpoint. It has nothing whatsoever to do with performance.
2. Good to use collections in place of cursors that do DML operations on large set of recordsBut using SQL is more efficient than using PL/SQL with bulk collects.
4. Optimize SQL statements if they need to
-> Avoid using IN, NOT IN conditions or those cause full table scans in queriesThat is not true.
-> See to queries they use Indexes properly , sometimes Leading index column is missed out that cause performance overheadAssuming "properly" implies that it is entirely possible that a table scan is more efficient than using an index.
5. use Oracle HINTS if query can't be further tuned and hints can considerably help youHints should be used only as a last resort. It is almost certainly the case that if you can use a hint that forces a particular plan to improve performance that there is some problem in the underlying statistics that should be fixed in order to resolve issues with many queries rather than just the one you're looking at.
Justin -
How to avoid Flickaring When Adding data in Addon User Matrix
Experts,
I am Adding Query Result in User Matrix one by one. but there is lots of Flicker.
how to Avoid this Flickering.
Bomiitems = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
If Bomtyp = "U" And BomNo = "0" Then
BOMItem = "SELECT Distinct T0.[Code], T1.[ItemName] , ( 1 / Isnull(T2.[Qauntity],0))* Isnull((T0.[Quantity]),0),('" & Quanti & "'/ Isnull(T2.[Qauntity],0))* Isnull((T0.[Quantity]),0) as "
BOMItem = BOMItem + " 'Quanti',T1.[Excisable],'N' as U_Rec , T1.[InvntryUom],T0.[Warehouse] 'Warehouse',T0.[IssueMthd]'IssMthd' FROM ITT1 T0 INNER JOIN OITM T1 "
BOMItem = BOMItem + " ON T0.Code = T1.ItemCode INNER JOIN OITT T2 ON T0.Father = T2.Code "
BOMItem = BOMItem + " WHERE T0.[Father] ='" & Icode & "'"
Bomiitems.DoQuery(BOMItem)
ElseIf Bomtyp = "U" And BomNo <> "0" Then
'BOMItem = "SELECT T0.[Code], T1.[ItemName] , ((T0.[Quantity]/ T2.[Qauntity])*'" & Quanti & "') as 'Quanti',T1.[Excisable],'N' as U_Rec FROM ITT1 T0 INNER JOIN OITM T1 ON T0.Code = T1.ItemCode INNER JOIN OITT T2 ON T0.Father = T2.Code WHERE T0.[Father] ='" & Icode & "'"
BOMItem = "SELECT T1.[U_Icode], T1.[U_IName],(1 / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) ,('" & Quanti & "' / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) as 'Quanti',T2.[Excisable], T0.[U_Rec],T2.[InvntryUom] ,T1.[U_Whs] 'Warehouse','B' AS 'IssMthd' "
BOMItem = BOMItem + "FROM [dbo].[@OITTA] T0 inner join [dbo].[@ITTA1] "
BOMItem = BOMItem + "T1 on t0.cODE = t1.Code INNER JOIN OITM T2 ON T1.[U_Icode] = T2.[ItemCode]"
BOMItem = BOMItem + " WHERE T0.[U_Icode] = '" & Icode & "' AND T0.[U_AltBom] ='" & BomNo & "' AND T0.U_Btyp = 'U' "
Bomiitems.DoQuery(BOMItem)
ElseIf Bomtyp = "P" Then
BOMItem = "SELECT T1.[U_Icode], T1.[U_IName],(1 / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0),('" & Quanti & "' / Isnull(Cast( T0.[U_Bqty] as Float) ,0)) * Isnull(Cast(T1.[U_Quanti] As Float),0) as 'Quanti',T2.[Excisable], T0.[U_Rec] ,T2.[InvntryUom],T1.[U_Whs] 'Warehouse','B' AS 'IssMthd' "
BOMItem = BOMItem + "FROM [dbo].[@OITTA] T0 inner join [dbo].[@ITTA1] "
BOMItem = BOMItem + "T1 on t0.cODE = t1.Code INNER JOIN OITM T2 ON T1.[U_Icode] = T2.[ItemCode]"
BOMItem = BOMItem + " WHERE T0.[U_Icode] = '" & Icode & "' AND T0.[U_AltBom] ='" & BomNo & "' AND T0.U_Btyp = 'P' "
Bomiitems.DoQuery(BOMItem)
End If
Bomiitems.DoQuery(BOMItem)
If Bomiitems.RecordCount > 0 Then
'RecCount1 = RecSet1.RecordCount
Bomiitems.MoveFirst()
i = 0
'osubForm .Freeze(True)
oMatrix = oForm.Items.Item("1000001").Specific
oMatrix.FlushToDataSource()
While Not (Bomiitems.EoF)
If i = 0 Then
oMatrix.AddRow()
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("LineId", 0, i + 1)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemCode", 0, Bomiitems.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemName", 0, Bomiitems.Fields.Item(1).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_BaseQty", 0, Bomiitems.Fields.Item(2).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PlanQty", 0, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IssueQty", 0, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whs", 0, Bomiitems.Fields.Item("Warehouse").Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IsueType", 0, Bomiitems.Fields.Item("IssMthd").Value)
Dim orsWhsDetails As SAPbobsCOM.Recordset
Dim strWhsDetails As String
orsWhsDetails = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
strWhsDetails = "SELECT T0.[OnHand], T0.[IsCommited], T0.[OnOrder],T1.[OnHand] FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] ='" & Bomiitems.Fields.Item(0).Value & "' AND T0.[WhsCode] ='" & Bomiitems.Fields.Item("Warehouse").Value & "' "
orsWhsDetails.DoQuery(strWhsDetails)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whsestk", 0, orsWhsDetails.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_AVILSTK", 0, (orsWhsDetails.Fields.Item(0).Value - Bomiitems.Fields.Item(3).Value))
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PLANTSTK", 0, orsWhsDetails.Fields.Item(3).Value)
oMatrix.LoadFromDataSource()
Else
oMatrix.FlushToDataSource()
oForm.DataSources.DBDataSources.Item("@TPROD1").InsertRecord(i)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("LineId", i, i + 1)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemCode", i, Bomiitems.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_ItemName", i, Bomiitems.Fields.Item(1).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_BaseQty", i, Bomiitems.Fields.Item(2).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PlanQty", i, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IssueQty", i, Bomiitems.Fields.Item(3).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whs", i, Bomiitems.Fields.Item("Warehouse").Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_IsueType", i, Bomiitems.Fields.Item("IssMthd").Value)
Dim orsWhsDetails As SAPbobsCOM.Recordset
Dim strWhsDetails As String
orsWhsDetails = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
strWhsDetails = "SELECT T0.[OnHand], T0.[IsCommited], T0.[OnOrder],T1.[OnHand] FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[ItemCode] ='" & Bomiitems.Fields.Item(0).Value & "' AND T0.[WhsCode] ='" & Bomiitems.Fields.Item("Warehouse").Value & "' "
orsWhsDetails.DoQuery(strWhsDetails)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_Whsestk", i, orsWhsDetails.Fields.Item(0).Value)
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_AVILSTK", i, (orsWhsDetails.Fields.Item(0).Value - Bomiitems.Fields.Item(3).Value))
oForm.DataSources.DBDataSources.Item("@TPROD1").SetValue("U_PLANTSTK", i, orsWhsDetails.Fields.Item(3).Value)
oMatrix.LoadFromDataSource()
End If
i = i + 1
Bomiitems.MoveNext()
oMatrix.LoadFromDataSource()
End While
oMatrix.LoadFromDataSource()
End If
Regards,
Pravin Bajifollow steps
1) Execute query so we can get data set
2) Clear matrix and data source (omatrix.clear(), oDBS.Clear())
3) Open loop
4) Insert record to oDBS using oDBS.InsertRecords(oDBS.Offset)
5) Then set value using oDBS.Setvalue(u2026u2026
6) Move next record
7) Finally close the loop
8) Matrix load from record set using oMatrix.LoadfromData()
it will be work -
How to Avoid wrong spell MD values at Qry selection
Hi all,
The issue is at Query Selection:
We set:
Query def. Filter value selection = Only values in infoprovider
Query Execution Filter Val. Selectn = Only values in InfoProvider
I want to see only Info provider(TD) values not Master values @ Qry selection for the info object (customer)
Example
Customer MD:
CID:
John - correct name
JOKN - Wrong spell
We Don't want to delete these values.
- NO records there in cube for (CID = JOKN) and in reports with the name JOKN
I want to see only JOHN in selection not JOKN(Wrong spell).
Please tell me how to avoid wrong spell values at Qry selection level without deleting Master data.
Thanks in advanceHello Nara,
One solution is to write customer-exit variable that will be populated only by correct values. You can archieve this by joining master data table with DSO active table
or master data table with dimension table and fact table(s).
Now restrict query with this non-input variable in restrictions and create input variable that will take place in default values.
But since it's customer master data you may encounter serious performance problems. I guess that's the reason why BEx doesn't do this by default.
BR
Ondrej -
How to avoid select with in a loop.
Hi friends,
can any tell how to avoid the select with in a loop for the following code, since it badly effecting my performance. if possible with code
SELECT matnr werks
FROM marc
INTO TABLE it_marc
FOR ALL ENTRIES IN it_ausp_1
WHERE matnr = it_ausp_1-objek AND
werks = p_werks
AND mmsta LE 60.
SORT it_marc BY matnr.
CLEAR wa_ausp_1.
CLEAR wa_tabix.
LOOP AT it_ausp_1 INTO wa_ausp_1.
wa_tabix = sy-tabix.
READ TABLE it_marc INTO wa_marc WITH
KEY matnr = wa_ausp_1-objek
BINARY SEARCH.
IF sy-subrc EQ 0.
ELSE.
DELETE it_ausp_1 INDEX wa_tabix.
ENDIF.
ENDLOOP. " LOOP AT it_ausp_1 INTO wa_ausp_1.
APPEND LINES OF it_ausp_1 TO it_tal.
IF it_tal[] IS NOT INITIAL.
LOOP AT t_plan_order INTO fs_plan_order.
SELECT r~rsnum
r~rspos
r~matnr
r~nomng
r~meins
r~plnum
r~bdter
r~ewahr
r~alprf
r~posnr
r~baugr
m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON rbaugr = mmatnr
AND rwerks = mwerks
FOR ALL ENTRIES IN it_tal
WHERE r~rsnum = fs_plan_order-rsnum
AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
APPEND LINES OF t_resb TO t_tacl.
ENDLOOP.SELECT r~rsnum r~rspos r~matnr r~nomng r~meins r~plnum r~bdter r~ewahr r~alprf r~posnr r~baugr m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON r~baugr = m~matnr
AND r~werks = m~werks
FOR ALL ENTRIES IN it_tal
WHERE r~rsnum = fs_plan_order-rsnum
AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
The logic of this select is completely weird. Whcih order of the db-tables should be used, which indexes?
On RESB matnr, werks and xloek are in one index, but rsnum not.
Are the conditions in fs_plan_order and it_tal connected or independent?
It is probably much faster, to leave the fs_plan_order condition away and check it on the result.
SELECT r~rsnum r~rspos r~matnr r~nomng r~meins r~plnum r~bdter r~ewahr r~alprf r~posnr r~baugr m~dispo
INTO TABLE t_resb
FROM resb AS r
INNER JOIN marc AS m
ON m~matnr = r~baugr
AND m~werks = r~werks
FOR ALL ENTRIES IN it_tal
WHERE AND r~matnr = it_tal-objek
AND r~xloek = ' '
AND r~werks = p_werks.
sort fs_plan_order by rsnum.
loop at it_tal in wa.
read table fs_plan_order
with key rsnum = wa-rsnum
binary search.
if sy-subrc eq 0.
append ...
endif.
endloop.
Siegfried -
How to avoid unions in sql quries
Hi All,
I have an sql statement in which I am using unions to get the data from two tables with different conditions. how can avoid UNIONs in my query, which will increase performance. please suggest.
SQL Query is :
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_cd cc
WHERE c.flextemplateid = cc.id AND cc.name = 'SoftwareDownload'
AND (c.PATH NOT LIKE '/auth%' AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT opt_url_path, locale
FROM urlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid =
(SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
UNION
SELECT PATH, locale
FROM bloburlregistry
WHERE master_assetid IN
(SELECT c.id FROM content_c c, content_c_mungo cm
WHERE c.id = cm.cs_ownerid AND cm.cs_attrid = (SELECT id FROM attribute WHERE name = 'Gated')
AND c.flextemplateid IN (SELECT id FROM content_cd WHERE name = 'Collateral')
AND cm.stringvalue = 'Yes'
AND (c.PATH NOT LIKE '/auth%'
AND c.PATH NOT LIKE '/gate%'))
Thank u.To increase performance you need to reduce the I/O. So when ever i tune a SQL the first thing i look for is that. If i have a table used multiple times i try to remove it and solve the required problem by just scanning the table once. But do to that we need to have good understanding of the data and there relation between tables. But we don't know anything about yours. Said that i came up with this.
select opt_url_path
, locale
from urlregistry
where master_assetid
IN
select c.id
from content_c c
left
join content_cd cc
on c.flextemplateid = cc.id
and (cc.name = 'SoftwareDownload' or cc.name = 'Collateral')
left
join content_c_mungo cm
on c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and cm.stringvalue = 'Yes'
where c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
and (
cc.flextemplateid is not null or
cm.cs_owner_id is not null
union
select PATH
, locale
from bloburlregistry
where master_assetid IN
select c.id
from content_c c
, content_c_mungo cm
where c.id = cm.cs_ownerid
and cm.cs_attrid =
SELECT id
FROM attribute
WHERE name = 'Gated'
and c.flextemplateid IN
SELECT id
FROM content_cd
WHERE name = 'Collateral'
and cm.stringvalue = 'Yes'
and c.PATH NOT LIKE '/auth%'
and c.PATH NOT LIKE '/gate%'
This is a untested code. You can give this a try and see if it gives the expected output and also if the performance improves. -
How to avoid ViewObject or ApplicationModule cache?
I am developing a web application using JSP, EJB (SessionBean) and BC4J.
How to avoid ViewObject or ApplicationModule cache?
Is there any method in Oracle API (oracle.jbo, oracle.jbo.server, ...) to do this?
nullObjects returned from queries against your session are the shared/cached instances and should not be changed. Changes applied directly against these instances will not be reflected in the database.
To apply changes against objects within a transaction and isolate these changes from other thread while they are pending you must use a UnitOfWork. The UnitOfWork will provide you a transactional isolated working copy where changes can be safely made. Then when the UnitOfWork is committed the minimal change-set is calculated and written to the database prior to being merged into the shared cache.
Some useful links into the documentation:
http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/undrstdg.htm#1110428
http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/xactions.htm#1127587
Doug -
How to avoid merged columns on conversion
Dear All,
I have built some reports using Oracle Developer Report Suit. All is well and working fine but when I send report output to Excel file I am facing following two issues:
1) It goes always to .xls file which is excel 97 format and having limit of maximum 65 thousands rows. Can I convert report to excel 2010 .xlsx file as my reports sometime contains large number of rows?
2) When I convert into excel all information comes normally with proper format but some of report columns occupy multiple excel columns which is causing difficulties in sorting and other function in excel. How to avoid it?
I would be glade to hear from you guys to resolve above issues.
Thanks!Zia wrote:
1) I have a detail report which contains more than 100 thousands rows. This report is already on menu and available to users. User have got an option on menu that they can select output either 'screen' or 'spreadsheet'. If user select option as 'spreadsheet', report open in excel file but in old excel and truncating excessive rows as .xls have limitation of maximum 65 thousands rows. I do not want to use 'csv' format as directly conversion into excel is more convinient for users. If report contains less than 65 thousands rows then everything is fine and no issues with the report. I hope I could explain real problem this time.65 thousands rows is the limitation of that version u use. I use Microsoft Office 2010 where limitation is 1048576 is a sheet.
One solution is uninstall the present Office version and use Office 2010.
2) Regarding second point, I have a summary report which is all fine and showing desired output in desired format. But when user want output in excel file, some of report columns occupy more than one columns and causing difficulties for users. Actually users do need to convert few reports into excel and work with formulas in excel but in this situation they have to do lots of changes in format before applying formulas. A sample screen shot of a report and converted report in excel file both can be seen on this link [https://skydrive.live.com/?cid=573511bde4261fe6#cid=573511BDE4261FE6&id=573511BDE4261FE6%21120]
I'm not sure about the solution. Most probably you have more space in repeating frame and cause this thing happen. shorter the space in the frame and try.
Hope this will help you.
Maybe you are looking for
-
Not able to release normal change document for development
Hello All We have Implemented ChaRM in SolMan 7.1 SP10 Have created the Project and activated Charm with required DEV/QA/PRD logical component and before creating the Maintenance cycle, we did a check in the project which showed all green.. We are ab
-
Sending Drop Down menu via email
Hey Guys I am editing a friends website and he wants to add a drop down bo to the contents page. I have populated the drop down box with the following code: myComboBox.addItem({data:1, label:"Where did you hear about us?"}); myComboBox.addItem({data:
-
OBIEE 10G deliver content dynamic name
For example, I want to send the answer report to a user every day via email. The name of the answer report is 'promotion aaa'. Is it possible to send the report as an excel attachment with name like promotion aaa [day], where day can be from a variab
-
Purchased new computer with Windows 7. Have Photosmart 1115 and LaserJet 1012 printers. As best I can tell, there are no updated drivers for these printers. If I an correct, does that mean that these machines are history?
-
Multiple range expanders in hardwired house
I'm trying to set up a single wifi network in a three story, huge, brick house in downtown Baltimore and can't figure out the best way to do it. I currently have the modem on the first floor and going into an older G router, from there it gives a wif