Regarding nested selects...........
Hi friends,
i want to use one query in that i have to use neseted selects.
can any one tel me example with considering performane also.
regards,
madhu.
Hi madhu,
SELECT tabname
INTO ls_dd02l
FROM dd02l
WHERE tabname LIKE c_feld
AND buffered IS NOT NULL.
SELECT tabname fieldname keyflag position
INTO CORRESPONDING FIELDS OF ls_dd03l
FROM dd03l
WHERE tabname = ls_dd02l-tabname
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
IF ( sy-subrc EQ 0 ).
wa-tabname = ls_dd03l-tabname.
wa-fieldname = ls_dd03l-fieldname.
wa-keyflag = ls_dd03l-keyflag.
wa-position = ls_dd03l-position.
APPEND wa TO itab.
ENDIF.
ENDSELECT.
ENDSELECT.
There are no practical limits to nested SELECTs, but as other repliers have already pointed out they quickly become a performance hog. I have stopped using them for years, and when I teach ABAP performance classes I also quote them as one of the top "don'ts". With nested selects, the number of calls to the DBMS can easily become enormous, putting the database server under stress.
A good alternative - the one I favour most myself - is to use SELECT INTO TABLE for the"outer" select, followed by appropriate SELECT FOR ALL ENTRIES statements to handle the inner levels.
ABAP joins are another alternative. When properly written, a join will be faster than a nested select. The problem is however that very often joins are not properly written. SELECT statements should always respect the KISS principle (keep it simple, stupid) and with a join it is very easy to violate that rule. A join over 2 tables should probably be OK, but with 3 or more tables you want to be very careful. If you really want to code a complex join, I recommend that you also code the same logic with different means (INTO TABLE/FOR ALL ENTRIES or even nested selects) and then compare that with the join.
regards,
Jayan.
Similar Messages
-
Performance Problem with Nested Select
I have an urgent performance question, I run a nested select like this one
SELECT tabname
INTO ls_dd02l
FROM dd02l
WHERE tabname LIKE c_feld
AND buffered IS NOT NULL.
SELECT tabname fieldname keyflag position
INTO CORRESPONDING FIELDS OF ls_dd03l
FROM dd03l
WHERE tabname = ls_dd02l-tabname
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
IF ( sy-subrc EQ 0 ).
wa-tabname = ls_dd03l-tabname.
wa-fieldname = ls_dd03l-fieldname.
wa-keyflag = ls_dd03l-keyflag.
wa-position = ls_dd03l-position.
APPEND wa TO itab.
ENDIF.
ENDSELECT.
ENDSELECT.
It is taking about 20sec, which is much too long.
How can I improve the performance.
Points rewarded!
S.B.Hi Siegfried,
As Vinay said u can use INNER JOIN to get the data from both database tables
or u can use FOR ALL ENTRIES statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
The above statement is from Library. Please check this link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
Tabular Conditions sub heading
SELECT a~tabname
b~fieldname
b~keyflag
b~position
FROM dd02l as a INNER JOIN dd03l as b
ON a~tabname = b~tabname
INTO TABLE itab
WHERE a~tabname LIKE c_feld
AND buffered IS NOT NULL
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
OR
SELECT tabname
INTO TABLE lt_dd02l
FROM dd02l
WHERE tabname LIKE c_feld
AND buffered IS NOT NULL.
IF NOT lt_dd02l IS INITIAL.
SELECT tabname fieldname keyflag position
INTO CORRESPONDING FIELDS OF TABLE itab
FROM dd03l
FOR ALL ENTRIES IN lt_dd02l
WHERE tabname = lt_dd02l-tabname
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
ENDIF.
Please check this link
/people/rob.burbank/blog/2007/03/19/joins-vs-for-all-entries--which-performs-better
You have to look at the primary keys..
MANDT
STLTY
STLNR
STLAL
STLKN
STASZ
MANDT
STLTY
STLNR
STLKN
STPOZ
You need the stlty for both tables stas and stpo
The on condition between stas and stpo is obvious, will help a
bit.
It would be much better, if you could add it to the WHERE Condition.
Do you know it?
If not, then as the BOM categories are not so many,
Try
select distinct stlty
from stas.
and add the values to you where condition as
AND s1-stlty in ( ....... )
This should improve the performance.
I don't kknow whether the BOM Categories can change in future.
instead of a fixed in, you could add a subselect from a customizing table.
I am quite confident that the solution I proposed will be much faster than the FOR ALL ENTRIES.
But with more complicated joins you really have to try it.
There is no general rule about the number of tables in a join, there are perfectly running joins with 5 tables
and there are porblems with 2 tables.
You must analyze the indexes, it it is clear which index will support the accesses then it will work fine.
The FOR ALL ENTRIES is by construction much slower!
Best regards,
raam -
Nested select statements.
Hi, I am writing a piece of code in which i use nested select statements for 4 tables to retrieve one column's data (ie: POSNR). But when i execute it, it takes way too long to get the data. I'm quite new to ABAP so very in need of your help. Thanks
REPORT z_impos_test.
TABLES: coss, "CO Object: Cost Totals for Internal Postings
afvc, "Operation within an order
prps, "WBS (Work Breakdown Structure) Element Master Data
imzo. "Table: CO Object - Capital Investment Prog.Pos.
TYPES: BEGIN OF st_impos,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF st_impos.
data: year TYPE coss-gjahr value '2007'.
DATA: t_output TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
st_output TYPE st_impos,
t_output2 TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
st_output2 TYPE st_impos.
SELECT objnr gjahr kstar FROM coss
INTO CORRESPONDING FIELDS OF st_output
WHERE ( objnr LIKE 'NV%' OR
objnr LIKE 'PR%' ) AND
gjahr = year.
SELECT SINGLE projn from afvc into CORRESPONDING FIELDS OF st_output
WHERE objnr = st_output-objnr.
APPEND st_output to t_output.
ENDSELECT.
SORT t_output BY objnr.
DELETE ADJACENT DUPLICATES FROM t_output.
LOOP AT t_output into st_output.
SELECT objnr pspnr
INTO CORRESPONDING FIELDS OF st_output2
FROM prps
WHERE objnr = st_output-objnr
AND pspnr = st_output-pspnr.
SELECT SINGLE posnr from imzo into CORRESPONDING FIELDS OF st_output2
WHERE objnr = st_output2-objnr.
APPEND st_output2 to t_output2.
ENDSELECT.
ENDLOOP.
LOOP AT t_output2 to st_output2.
WRITE: st_output2-posnr.
ENDLOOP.
Edited by: Jacie Johns on Apr 23, 2009 11:26 PMHI John,
Try to avoid INTO CORRESPONDING FIELDS in SELECT statement.
As you are not using PSPNR and POSNR fields in the first SELECT statement. If you remove these fields, in structure, INTO CORRESPONDING FIELDS can be avoided. Create a separate structure with the fields that are required for T_OUTPUT table (i.e. create another structure with only first 4 fields, as T_OUTPUT1.
And as mentioned in your code,
WHERE objnr = st_output-objnr
AND pspnr = st_output-pspnr
in select statement, ST_OUTPUT-PSPNR value is not fetched in the previous select statements.
Create Another structure with fields OBJNR, PSPNR, POSNR for table T_OUTPUT2 to store the data from tables, PRPS and IMZO.
Use JOINS and FOR ALL ENTRIES to fetch the desired data.
The sample code is as follows:
===
TYPES: BEGIN OF ty_output1,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
END OF ty_output1,
BEGIN OF ty_output2,
objnr TYPE coss-objnr,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF ty_output2,
BEGIN OF ty_output3,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF ty_output3.
data: year TYPE coss-gjahr value '2007'.
DATA:
wa_output1 TYPE ty_output1,
wa_output2 TYPE ty_output2,
wa_output3 TYPE ty_output3,
t_output1 TYPE STANDARD TABLE OF ty_output1 ,
t_output2 TYPE STANDARD TABLE OF ty_output2 ,
t_output3 TYPE STANDARD TABLE OF ty_output3..
SELECT cobjnr cgjahr ckstar aprojn FROM coss as c
INNER JOIN afvc as A on aobjnr = cobjnr
INTO table t_output1
WHERE ( c~objnr like 'NV%' or
c~objnr like 'PR%' ) and
c~gjahr = year.
SELECT pobjnr ppspnr i~posnr FROM prps as P
INNER JOIN imzo AS I on pobjnr = iobjnr
INTO TABLE t_output2
for all entries in table T_OUTPUT1
WHERE p~objnr = t_output1-objnr.
SORT : t_output1 BY objnr,
t_output2 BY objnr.
DELETE ADJACENT DUPLICATES FROM : t_output1 COMPARING objnr,
t_output2 COMPARING objnr.
LOOP AT t_output1 INTO wa_output1
READ TABLE t_output2 INTO wa_output2 WITH KEY objnr - wa_output1-objnr BINARY SEARCH.
if sy-subrc = 0.
MOVE <wa_output1 fiels> and <wa_output2 fields> to WA_OUTPUT3.
append wa_output3 to T_OUTPUT3.
endif.
ENDLOOP.
Hope this will solve your problem.
Regards,
Sai Prasad -
Is it possible to nest SELECT statements?
Greetings community,
Another newbie’s question it is. Looking tutorials and some posts here I’ve been advised not to pull entire table through the local network, and torture client machines’ processors and memory. It’s been said that better solution is to
pull just one part of the table.
So, imagine this: you want to make a part of your app that would allow your user to view list of orders. So you put one data grid view on the form, pull last 20 headers from the table into it and leave to user to choose one to be opened
in another form. If user doesn’t find header they want, they press page up for example and previous 20 headers are loaded into data grid view. Of course, user could filter headers list by customer, or by distribution lane (having all customers residing in
one part of the town), or whatever more, but let’s not complicate things at this moment, because I’m practically in the beginning.
I’m trying to make a stored procedure that would load penultimate 20 headers when user presses page up. So, not knowing any better, I created table variable that has the same structure as Orders table with one difference: OrderID column,
which is identity (auto incremented) in Orders table, here is simply defined as bigint not null. Community member Visakh16 warned me few months ago it’s the bad practice to put self-incrementing columns in table variables.
At this moment there’s a query on my screen, which waits to become store procedure. After boring part with table variable definition, it goes like this:
INSERT INTO @OrdersTemp SELECT TOP 40 * FROM dbo.Orders ORDER BY OrderID DESC
SELECT TOP 20 * FROM @OrdersTemp ORDER BY OrderID ASC
To put that simply, I pull last 40 headers into table variable, and then pull first 20 from there. This thing works, and I just have to replace 40 with parameter, for every page up or down.
Now I have few questions.
-Is there some better way (considering performance) to achieve that? Here is the place where I wanted to ask the question from the title of the post. I don’t know much about T-SQL, and I’m not sure about the proper syntax to nest SELECT
statements, if something like that is even possible
-Is there any better way (some built-in function) to find about the count of the rows in one table than
SELECT COUNT(OrdersID) FROM dbo.Orders
Thanks for any suggestions.Hi Erland,
Sorry for the very late reply, but I said that I would start another thread when I find more free time to dedicate it to this, so I didn’t really expected you to reply anymore. I didn’t really check here for more than a week, and I glanced
at mail accidentally.
As for the negative result I got, its measurement unit is microsecond, so it doesn’t go out of margins you had experienced.
As for the number of cores, you got me surprised there. I use express edition of SQL server. Last time I checked was SQL server 2012 express, and in specifications it said that express edition is limited to 1 processor core, 1GB of RAM
and creates up to 10GB database file. I don’t believe they changed any of those specifications. It was generous enough when they doubled size of DB file few editions ago. Still, it appears that “one processor core for express edition” statement has some gray
areas in it.
However, at this moment I’m just learning, and I just wanted some way to test how efficient my queries are. I don’t have a real biz problem to solve. I don’t expect that any real performance problem should rise in years of everyday work
of populating database. What I expect is performance impact when it comes to creating reports, but after all, I don’t think that my boss would create reports by himself. I believe that creating reports would be my task, and I will be doing it after hours,
being the only user at the moment. Or maybe I could make de-normalized copy of database that would be populated after hours to make it possible for my boss to get his reports faster by himself, as I’ve heard that was the way of making BI in older non-express
editions.
So, I do suggest that we finally close this thread for sake of other readers. I’ll start another one with this subject when I find the time to do it.
Again, thanks for being with me along this journey. -
Using nested select in oracle functions
hi, im new to oracle functions, and im trying to write a function using a nested select statment, but i get the error
Error: PLS-00428: an INTO clause is expected in this SELECT statement
can anyone help point out what i am doing wrong, The sql select statment works on a worksheet, so i guess its the way i am using the function
create or replace function Media_Object_Name(Detail_id Number) return varchar2 as
Result varchar2(300);
begin
select promo_name from promo where promo_id =
(select promo_id from promo_plan where promo_plan_id =
(select promo_plan_id from event_promotion where detail_id = Detail_id)) into ;
return(Result);
end Media_Object_Name;
thanks
jamesThe into clause should go here:
SELECT promo_name
INTO Result
FROM promo
WHERE promo_id = (SELECT promo_id
FROM promo_plan
WHERE promo_plan_id = (SELECT promo_plan_id
FROM event_promotion
WHERE detail_id = detail_id));I don't know about your data modell, but are you sure you need nested selects?
C. -
Prompting for user input in nested select statements
I recently rewrote a query to use a nested select statement instead of specifying every SELECT field on the GROUP BY line. Here's the query which works perfectly with hard-coded values of '030', '01/01/11', and '12/31/11'.
SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country], T1.[TotalSales]
FROM OCRD T0
INNER JOIN
(SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
FROM OINV I
WHERE left (I.[CardCode], 3) = '030' AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
GROUP BY I.[CardCode]) T1
ON T0.[CardCode] = T1.[CardCode]
ORDER BY T0.[CardName]
When I try to prompt for the left 3 characters of the CardCode (or the dates), ie.
WHERE left (I.[CardCode], 3) = [%0] AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
I get an error "Column 'OCRD.CardName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause".
It's like putting a user variable in the inner SELECT made it part of the outer SELECT which is exactly what I was trying to avoid by re-writing this query with the inner SELECT.
Can anyone explain what SQL Server is doing here and how to fix it?Thanks Gordon. That's how I originally wrote the query and it works fine. But I was disturbed that I had to GROUP BY every field in my SELECT statement when I really only wanted to group by CardCode. So I did some research and came up with this where the inner select still groups by only CardCode and still takes user input. I don't really understand why you need the commented SELECT statements in the SET lines, but you do. Something about using real table fields for variables.
DECLARE @startDate datetime
DECLARE @endDate datetime
DECLARE @rep varchar(10)
SET @rep /* SELECT T0.[CardCode] FROM ORDR T0 WHERE T0.[CardCode] */ = '[%0]'
SET @startDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%1]'
SET @endDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%2]'
SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country], T1.[TotalSales]
FROM OCRD T0
INNER JOIN
(SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
FROM OINV I
WHERE left (I.[CardCode], 3) = @rep AND (I.[DocDate] >= @startDate AND I.[DocDate] <= @endDate)
GROUP BY I.[CardCode]) T1
ON T0.[CardCode] = T1.[CardCode]
ORDER BY T0.[CardName]
FOR BROWSE -
Ref cursor based on join or nested select is empty
Hi ,
We have a Stored procedure which returns 27 ref cursors.
We are populating this data into a suitable data set using OracleDataAdapter (.fill).
Refcursors that the data they hold is from a join or nested select are result empty.
The other refcursors are fine.
If running the stored procedure in the database (from another SP for instance) all refcursors are full of data.
Can someone direct me for a solution or even working work around ?
ThanksHi Again ,
No, The cursors are not any of group by with some aggregations of any sort. Just plain and simple joins or nested queries (Select... from ... where ... in (select ...). Some of the data is taken from temporary tables.
For the last question i am using the production ODP with the last oraMTS.
This problem is really stopping us from going to production in early march ....
A possible work around we thought about (but cost dearly ...) is to fill the data from the tables into a temporary one and then base the cursor on a query on this table. This workaround can last only a few weeks at the customer.
Regards -
DB Adapter Query - Polling using nested select
When polling a table to initiate a BPEL process, can I use a nested select in the expression.
The visual expression builder does not currently support this so you need to specify the raw sql directly.
If you use the DeletePollingStrategy there is a way you can specify the exact sql string for both the 'select' and the after read 'delete'. So if you write the where clause yourself it can contain nested selects.
This is the readme from the new PureSQLSelect database adapter sample. Also you may want to look at the PureSQLPolling sample.
This sample shows you how you can bypass the designer's visual where clause builder to specify arbitrarily complex sql strings for your selects.
Like the other samples, this sample uses the basic Movies schema.
The Steps:
Create a basic select. Made sure it has the same name and number of input parameters as you will need for your sql string. In this case create a single input parameter and call it 'genre_param'.
Create a trivial where clause in the wizard expression builder using genre_param. I.e. genre.like(genre_param)
Ideally run the sample once just to make sure everything else works and to get a template SQL. The select ... FROM ... part will be the same.
Open the toplink_mappings.xml file. Look for an element called <database-query>. There will likely only be one. A sample is presented here:
<query-manager>
<descriptor-query-manager>
<existence-check>Check cache</existence-check>
<descriptor-named-queries>
<database-query>
<query-name>selectByGenreSelect</query-name>
<query-should-maintain-cache>true</query-should-maintain-cache>
<cascade-policy>1</cascade-policy>
<should-bind-all-parameters>undefined</should-bind-all-parameters>
<should-cache-statement>undefined</should-cache-statement>
<should-use-wrapper-policy>true</should-use-wrapper-policy>
<query-timeout>0</query-timeout>
<query-arguments>
<string>genre_param</string>
</query-arguments>
<query-argument-types>
<values>java.lang.String</values>
</query-argument-types>
<reference-class>PureSQLSelect.Movies</reference-class>
<refresh-identity-map>false</refresh-identity-map>
<cache-usage>2</cache-usage>
<lock-mode>0</lock-mode>
<distinct-state>0</distinct-state>
<query-indirection>
<in-memory-query-indirection>
<policy>0</policy>
</in-memory-query-indirection>
</query-indirection>
<main-expression>
<expression>
<operator-type>AND</operator-type>
<expression-list>
<expression>
<operator-type>Like</operator-type>
<first-argument>
<argument>
<query-key-name>genre</query-key-name>
<outer-join>false</outer-join>
<to-many>false</to-many>
<argument-class>oracle.toplink.tools.workbench.expressions.QueryableArgumentRepresentation</argument-class>
</argument>
</first-argument>
<second-argument>
<argument>
<parameter-name>genre_param</parameter-name>
<argument-class>oracle.toplink.tools.workbench.expressions.ParameterArgumentRepresentation</argument-class>
</argument>
</second-argument>
<expression-class>oracle.toplink.tools.workbench.expressions.BinaryExpressionRepresentation</expression-class>
</expression>
</expression-list>
<expression-class>oracle.toplink.tools.workbench.expressions.CompoundExpressionRepresentation</expression-class>
</expression>
</main-expression>
<type>oracle.toplink.queryframework.ReadAllQuery</type>
</database-query>
</descriptor-named-queries>
</descriptor-query-manager>
</query-manager>
We want to switch this query from using a high-level expression to a pure sql string. You will remove the <main-expression> element and replace it with a <sql-string> element of your own devising.
Your replacement should look something like this:
<query-manager>
<descriptor-query-manager>
<existence-check>Check cache</existence-check>
<descriptor-named-queries>
<database-query>
<query-name>selectByGenreSelect</query-name>
<query-should-maintain-cache>true</query-should-maintain-cache>
<cascade-policy>1</cascade-policy>
<should-bind-all-parameters>undefined</should-bind-all-parameters>
<should-cache-statement>undefined</should-cache-statement>
<should-use-wrapper-policy>true</should-use-wrapper-policy>
<query-timeout>0</query-timeout>
<sql-string>SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM MOVIES WHERE (upper(GENRE) LIKE upper(concat(concat('%', #genre_param), '%'))) ORDER BY TOTAL_GROSS desc</sql-string>
<query-arguments>
<string>genre_param</string>
</query-arguments>
<query-argument-types>
<values>java.lang.String</values>
</query-argument-types>
<reference-class>PureSQLSelect.Movies</reference-class>
<refresh-identity-map>false</refresh-identity-map>
<cache-usage>2</cache-usage>
<lock-mode>0</lock-mode>
<distinct-state>0</distinct-state>
<query-indirection>
<in-memory-query-indirection>
<policy>0</policy>
</in-memory-query-indirection>
</query-indirection>
<type>oracle.toplink.queryframework.ReadAllQuery</type>
</database-query>
</descriptor-named-queries>
</descriptor-query-manager>
</query-manager>
Gotchas:
The tempation to start writing pure sql may be terrible to some, but it was intentionally left out of the wizard for good reasons. Please be wary of the following when specifying pure sql:
-There is a way to set the pure sql string in the Mapping Workbench, but when you edit the partnerlink to refresh the toplink_mappings.xml you may get an exception due to the query being in a pure sql format. For this reason you need to manually edit the toplink_mappings.xml, and again every time your run the wizard and hit finish after that.
-The #genre_param is a TopLink convention for writing a sql string which still takes parameters. At runtime if you enter 'Action' in the bpel console, you will see this sql:
SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM SYSTEM.MOVIES WHERE (GENRE LIKE ?)
bind => [Action]
The #genre_param gets replaced with the value of the input parameter genre_param.
-When specifying pure sql you should be aware of the following:
-maintenance issues
-loss of database platform independence
-The sql needs to conform with the way TopLink works. It is recommended that you do not change the SELECT ... FROM ... part of the query. TopLink's design is to read from one table at a time. If an Employee has an Address, then the Address is read with a hidden relationship query. There are two advanced TopLink features which optimize reading from multiple tables, called joinedAttribute and batchAttribute reading, but the combination of these features with raw sql was not explored here. So to avoid danger you can only really affect the top level query, and only rewrite the where clause.
-The pure sql route does not interact with most TopLink features, especially batch reading (on by default), and can not be combined with the following:
-LogicalDeletePollingStrategy
-SequencingPollingStrategy (LastUpdated, LastReadId, File)
These features extend the selection criteria at runtime. -
Is there any limitation of nested select.
Is there any limitation of nested select.If yes please let me know.
Hi,
There are no practical limits to nested SELECTs, but as other repliers have already pointed out they quickly become a performance hog. I have stopped using them for years, and when I teach ABAP performance classes I also quote them as one of the top "don'ts". With nested selects, the number of calls to the DBMS can easily become enormous, putting the database server under stress.
A good alternative - the one I favour most myself - is to use SELECT INTO TABLE for the"outer" select, followed by appropriate SELECT FOR ALL ENTRIES statements to handle the inner levels.
ABAP joins are another alternative. When properly written, a join will be faster than a nested select. The problem is however that very often joins are not properly written. SELECT statements should always respect the KISS principle (keep it simple, stupid) and with a join it is very easy to violate that rule. A join over 2 tables should probably be OK, but with 3 or more tables you want to be very careful. If you really want to code a complex join, I recommend that you also code the same logic with different means (INTO TABLE/FOR ALL ENTRIES or even nested selects) and then compare that with the join. By the way: don't just compare the performance, also make sure that the two return the same data. You wouldn't be the first to code a really fast join which unfortunately returns incorrect results. -
Nested selects in finder query
Hi!
Does anyone know whether one can express nested selects
with WL QL or EJB QL?
E.g. if one wants to express something like this in a
deployment descriptor for an CMP EJB:
SELECT * FROM tableA WHERE someID IN
(SELECT someID FROM tableB WHERE someColumn = ?)
cheers
-joHi!
Does anyone know the status of this issue?
cheers
-jo
On Wed, 02 May 2001 16:31:49 -0700, thorick <[email protected]>
wrote:
Hi
SubQueries are currently not supported. We targeting support for them
in
our next Major release (after the next Minor release that's due out
next)
thorick -
Why cannot populate value in nested:select onchange field???
<div class="labelledField">
<nested:select styleId='<%="pvqList.questions"+index.intValue()+".questionDropDown"%>' property="questionDropDown" styleClass="formFieldSelect" tabindex='<%=""+((5*index.intValue())+1)%>' onchange="togglePVQ('customQuestion<%=index.intValue()%>FieldLabelPair','<%=index.intValue()%>');return false;">
<option value=""><cibc:text key="ref.text.app.changePVQStep1.dropdown.selectAQuestion"/></option>
<option value="">--------------------</option>
<option value="CUSTOMQUESTION">Create Custom Question</option>
<option value="">--------------------</option>
</nested:select>
<a href="# tabindex='<%=""+((5*index.intValue())+2)%">' onclick="togglePVQ('customQuestion<%=index.intValue()%>FieldLabelPair','<%=index.intValue()%>');return false;">
try</a>
</div>
Outside nested:select, onclick can correctly populate to onclick="togglePVQ('customQuestion1FieldLabelPair','1');return false;"
but onchange in nested:select cannot populate, it only show :
onchange="togglePVQ('customQuestion<%=index.intValue()%>FieldLabelPair','<%=index.intValue()%>');return false;"
why??? How to solve it??
please help.Fabio,
1) what settings do you use for Default Value Type and Default Value?
2) which error is raised?
brgds,
Peter
Blog: http://www.oracle-and-apex.com
ApexLib: http://apexlib.oracleapex.info
BuilderPlugin: http://builderplugin.oracleapex.info
Work: http://www.click-click.at and http://www.wirsindapex.at -
Sql Query Error (9i) nested select with OleDB
I have the following query which works fine when used with Sqlplus, but fails when called from within crytal reports (using an OleDB connection). I saw an open Oracle bug number 3025605 on some website, but haven't been able to look up any additional information on the error. The query fails with Ora-00972.
SELECT "CLIENTS"."CLTFIRSTNAME",
"CLIENTS"."CLTLASTNAME",
"CLIENTS"."CLTMIDDLENAME",
"SCHEDULE"."SCSESSIONDATE",
(SELECT r.REMPFIRSTNAME||' '||r.REMPLASTNAME
FROM REFAGENCYEMPLOYEES R WHERE "R"."REMPLOYEEID" = "SCHEDULE"."SCREFPERSON1ID") REFAGENT1,
(SELECT r.REMPFIRSTNAME||' '||r.REMPLASTNAME
FROM REFAGENCYEMPLOYEES R WHERE "R"."REMPLOYEEID" = "SCHEDULE"."SCREFPERSON2ID") REFAGENT2,
"CODELOOKUP"."CODELISTNAME"
FROM "POBJS"."CLIENTS" "CLIENTS",
"POBJS"."SCHEDULE" "SCHEDULE",
"POBJS"."CODELOOKUP" "CODELOOKUP"
WHERE ("CLIENTS"."CLIENTID"="SCHEDULE"."SCCLIENTID")
AND ("SCHEDULE"."SCEXAMTYPE"="CODELOOKUP"."CODEVALUE")
AND "CODELOOKUP"."CODELISTNAME"='EXAM TYPES'
Thanks for any help.Thanks for the information. I worked around the problem by calling a function that basically runs the nested select statement and returns a value.
pobjs.getrname("SCHEDULE"."SCREFPERSON1ID") AS AGENT1,
"CODELOOKUP"."CODELISTNAME"
FROM "POBJS"."CLIENTS" "CLIENTS", ........ -
Update statement with nested selects and alias usage
Hello, we are trying to build an update statement like this...
update table1 t1
set attr1 = ( select someattr
from (nested select 1) as aux1
(nested select 2 (nested select 2.1 + nested select 2.2)) ) as aux2
where some_join_clauses
where t1.attr2 = 123
and t1.attr3 = 'abc'
Alias t1 shound be known at the level of nested select 1,2 and 2.1, 2.2? We are receiving an error message saying that t1.someattr is an invalid identifier. Can you help? Thanks!mauramos wrote:
Hello, we are trying to build an update statement like this...
update table1 t1
set attr1 = ( select someattr
from (nested select 1) as aux1
(nested select 2 (nested select 2.1 + nested select 2.2)) ) as aux2
where some_join_clauses
where t1.attr2 = 123
and t1.attr3 = 'abc'
Alias t1 shound be known at the level of nested select 1,2 and 2.1, 2.2? We are receiving an error message saying that t1.someattr is an invalid identifier. Can you help? Thanks!You can only reference elements nested 1 level deeper in a correlated update statement.
I'd suggest you try with the MERGE statement, or alternatively, post some sample data (insert statements) and table DDL (create statements), with an 'expected output' description and we can try to help you build a suitable statement. -
Nested Selection Screen Blocks
Hi friends,
My requirement is to display the two nested blocks in the selection screen and the radio button parameters defined should come in a single group.
as below........
! Begin Block1
! * Radio Button 1!
! Begin Block2
! * Radio Button 2 !
! * Radio Button 3 !
! * Radio Button 4 !
! End Block2 !
! End Block 1 !
My Requirement is all Radio Buttons 1 2 3 & 4 should be under one group only. I just need nested frames as shown above
Thanks & Regards,
Kumar.Hi,
In one group you can not declare only one radio button, you need atleast two radio button for a group.
if there is a single radio button only, then better you make it as check box.
Nesting of blocks is possible.
you can do that.
In one block there should be atleast two radio button for using Group.
regards,
Ruchika
Reward if useful................ -
How to avoid the below nested select statement
Please any one help me how this select statemet is working and how to avoid the nesetd select statement .
if we avoid below nested , does it improve performace ?
select field1 field2
into table w_feeds
from ZTable as t
where field2 in r_feedf1
and POSITION_POSTDT =
( SELECT MAX( position_postdt ) FROM zTable
where position_postdt le r_pdate-high
and field1 = t~field1 ).
Thanks in Advace.Hi,
Instead of nested query go for two separate queries. I see you are querying on the same table...so better go by this approach
select field1 field2 POSITION_POSTDT
into table w_feeds
from ZTable
where field2 in r_feedf1.
Remove the where condition on POSITION_POSTDT
Sort the table w_feeds by POSITION_POSTDT Descending; So you will get data pertaining to Max Position_Postdt.
Finally delete the other entries which are not Max.
This will enhance the performance over the nested query.
Regards
Shiva
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM
Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM
Maybe you are looking for
-
Hi: - I am currently prototyping a plug-in but I have some questions: - 1) At the 'All Metrics' table, what is the intent of the 'Last Upload' field, and how is this field updated? - I have created some metrics but for some metrics the 'Last Upload'
-
I am trying to transfer my music and apps from my iPod Touch to my laptop computer's itunes library so that I can update the IOS. I have tried "Transfer Purchases from iPod Touch under File/Devices and nothing seems to happen. The itunes library on
-
I have to enter my details all the time in newly updated Aperture 3.4.3
Hi, I have to enter all my details again and again in Aperture 3.4.3, any idea why? cheers
-
Ultrasearch problems with Frames
I am having problems with Ultrasearch crawling pager with frames. When my ultrasearch crawler encounters a page with frames it does not crawl any of the frames. Is this because it is looking for an <a href> tag to follow or is there something I am mi
-
How can I stop iPhoto from trying to import albums from MoblieMe?
Since 1 July iPhoto tries to import albums from MobileMe upon each start-up. I never created any album in MobileMe so the attempt to imort fails. I can then only click 'Retry' or 'Remind me later'. There is no option to tell iPhoto to not import any