How to select records considering 200 entries at a time
Dear All,
Need some help.
Scenario :-
I have an idoc number range in select options.Instead of selecting all the
records falling in this range and populating the final internal table i want
that every 200 idoc no.s (from select-options)be copied into a range field and then this field be used
repetitively (until idoc nos are finished)for populating final data.
The reason for doing this way is performance factor.
Please suggest how to do this.
Hi Deepali,
check the package size addition of select statement.
... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab [PACKAGE SIZE n]
Effect
If the result set consists of multiple lines, an internal table itab of any table type can be specified after INTO or APPENDING. The row type of the internal table must meet the prerequisites.
The result set is inserted into the internal table itab line-by-line; a sorting process is executed in the case of a sorted table. If INTO is used, the internal table is initialized before the first line is inserted. Previous lines remain intact if APPENDING is used.
Before any assignment of a line of the result set, an initial row of the internal table itab is created and the line of the result set is assigned to this row. When assigning a line of the result set to a row of the internal table with or without CORRESPONDING FIELDS, the same rules apply as when assigning to an individual work area wa (see above).
If the PACKAGE SIZE addition is not used, all lines of the result set are inserted in the internal table itab and the ENDSELECT statement must not be specified after SELECT.
If you specify the PACKAGE SIZE addition, all lines of the result set for SELECT are processed in a loop, which must be closed with ENDSELECT. The lines are inserted in the internal table itab in packages of n lines. n must be a type i data object that contains the number of lines. If the value of n is smaller than 0, an exception that cannot be handled occurs. If n is equal to 0, all lines of the result set are inserted in the internal table itab. If used in the FETCH statement, n lines are extracted from the current cursor position.
If INTO is used, the internal table is initialized before each insertion and, in the SELECT loop, it only contains the lines of the current package. If APPENDING is used, a further package is added to the existing rows of the internal table for each SELECT loop or for each extraction using FETCH.
After ENDSELECT, the content of itab is not defined if INTO is used - that is, the table can either contain the lines of the last package or it can be initial. If APPENDING is used, the content of itab retains the state of the last loop pass.
Notes
In the case of an internal table with a unique key, an exception that cannot be handled occurs if an attempt is made to create a duplicate entry.
If the addition PACKAGE SIZE is specified together with FOR ALL ENTRIES, it is not passed to the database system, but is applied to the result set on the application server, after all selected rows have been read.
Thanks,
Vinod.
Similar Messages
-
How to select records in ALV using FM
Hi guys,
How to select records in ALV using FM. Not the OO method. Thx in advance!
KunhI
by using REUSE_ALV_FIELDCATALOUG_MERGE. Iys fill field catalouge table as per internal table description. Then use REUSE_ALV_GRID_DISPLAY for display ALV REPORT.
**Please reward suitable points***
With Regards
Navin Khedikar -
Select records based on the closest given time
Dear SQL gurus,
I have a table T1:
Name Null? Type
ID NOT NULL NUMBER(5)
MOMENT NOT NULL DATE [DD.MM.YYYY HH24:MI]
MEASUREMENT NOT NULL NUMBER(8,3)
Example (ID, MOMENT, MEASUREMENT)
-- START OF EXAMPLE --
9380 18.11.2000 03:45 17.6
9380 18.11.2000 04:30 17.3
9380 18.11.2000 05:45 16.8
9380 18.11.2000 06:15 16.8
9380 18.11.2000 07:00 16.2
9380 18.11.2000 07:30 16.2
9380 18.11.2000 08:15 16
9380 18.11.2000 08:45 15.7
9380 18.11.2000 09:30 15.4
9380 18.11.2000 10:00 15.4
9380 18.11.2000 11:15 15.4
9380 18.11.2000 11:45 15.4
9380 18.11.2000 12:30 15.4
9380 18.11.2000 13:00 15.4
9380 18.11.2000 13:45 15.4
--- END OF EXAMPLE --
How to select records based on the:
- time period specified by the day only [DD.MM.YYYY] - CONDITION 1
- with values for 6AM only, and if not available, with values closest to 6AM - CONDITION 2
(if the time gap in MOMENT field is too big, lets say > 5h then choose the average between the value before 6AM (ex. 4:15AM) and the value after the 6AM (ex. 9:45AM))
CONDITION 1 (something like): moment between '01.01.2005' and '31.12.2004' - this is OK
CONDITION 2: I do not know how to formulate, especially if 6AM value is not availabe, and I have to find the closest available value, or get the avergae from the two adjacent values.
Maybe cursor magic??? Thanks a lot for your help.
RadoAbout condition two, would the following select be of use to you? Picking the first record could be achived by rownum, analytic function, etc.
WITH t1 AS (SELECT 9380 id, TO_DATE('18.11.2000 03:45', 'dd.mm.yyyy hh24:mi') moment, 17.6 measurement
FROM dual
UNION
SELECT 9380 id, TO_DATE('18.11.2000 04:30', 'dd.mm.yyyy hh24:mi') moment, 17.3 measurement
FROM dual
UNION
SELECT 9380 id, TO_DATE('18.11.2000 05:45', 'dd.mm.yyyy hh24:mi') moment, 16.8 measurement
FROM dual
UNION
SELECT 9380 id, TO_DATE('18.11.2000 06:15', 'dd.mm.yyyy hh24:mi') moment, 16.8 measurement
FROM dual
SELECT id, moment, measurement, diff
FROM (SELECT id, moment, measurement,
moment - TO_DATE(TO_CHAR(moment, 'dd.mm.yyyy ') || '06:00', 'dd.mm.yyyy hh24:mi') diff
FROM t1
ORDER BY abs(diff) asc, SIGN(diff) desc;
C. -
Selecting records from multiple dates but specific time
Hi:
I've to select records of multiple dates but the time should be 00:00:00 to 06:00:00 (i.e. 12 AM - 6 AM)
For date part this can be done:
WHERE
START_TIME BETWEEN TO_DATE('04-01-2012', 'MM-DD-YYYY') AND TO_DATE('04-05-2012', 'MM-DD-YYYY')
But how can I fix the time mentioed above.
Please let me know.
Thanks/TanvirWHERE
START_TIME BETWEEN TO_DATE('04-01-2012', 'MM-DD-YYYY') AND TO_DATE('04-05-2012', 'MM-DD-YYYY')
and start_time - trunc(start_time) between 0 and 6/24start_time - trunc(start_time) will give you the fraction of a day. So 6/24 means 06:00.
(When you use to_char(trunc(sysdate,'hh'),'hh24') between 0 and 6 you will also retrieve records with start_time 06:01 for example. So this would not meet your requirements as far as I understood.)
Edited by: hm on 10.04.2012 01:26 -
How to select records in batch?
Hi Friends.
I want to select 10 lacs records. But if i used for all entries also it is giving error of time out. now i want to select records ina batch og 100000. Means forst it will select 100000 records and move in a internal table ..after that it will again fetch next 100000 records and append in that internal table like that..Is it possible..how to do this? i am selecting BELNR from BKPF and using FOR ALL ENTRIES fetching records from BSEG. requirement is such as i have to fetch records from BSEG only and not from BSID,BSIK... like tables..
Please help me...its urgent friends....Hi ..
My program is not a normal abap program..it is a RFC. actually requirement is to fetch data from sap and send it to squ server database. So non sap application execute the RFC. so i cant run this it in background...is it possible to run RFC in background.. -
How to select records based on Max/Min on different columns and group by
I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
a b c d e
1 1 1 2 1
1 1 1 6 4
1 1 1 6 3
when i group by a,b i am expecting the record 1 6 3
Please help me with this.. Thanks in advance....Hi,
Welcome to the forum!
962163 wrote:
I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
a b c d e
1 1 1 2 1
1 1 1 6 4
1 1 1 6 3
when i group by a,b i am expecting the record 1 6 3It looks to me like "1 6 1" is the correct answer. You're asking for the lowest value of e, and 1 is lower than 3.
Maybe you don't want MIN (e). Explain why you want 3 (that is, how you decided that 3 is the correct value for the last column) and someone will help you code it.
Edited by: Frank Kulash on Sep 28, 2012 6:17 PM
Whenever you have a problem, you should psot CREATE TABLE and INSERT statements for your sample data. That way, the people who want to help you can re-create the problem and test their ideas. It often helps to clarify the problem, too. since this is your first message, I'll do it for you:
CREATE TABLE table_x
( a NUMBER
, b NUMBER
, c NUMBER
, d NUMBER
, e NUMBER
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 2, 1);
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 4);
INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 3);
COMMIT; -
How to select records with certain fields unique while others not
Hi,
For example, I have table with 6 columns, called 'A', 'B', 'C', 'D', 'E', 'F'. There's no unique constraint built-in, and I would like to select records that have both column 'A' and 'B' unique. What should the sql statement look like?
Columns 'C', 'D', 'E', 'F' can have same data in different records or null, not a concern.
Thanks.select A, B, max(C), max(D), max(E), max(F) from <your_tab>
group by A, B
select * from (select t.*, row_number() over (partition by A,B order by null) rn from <your_tab> t)
where rn=1they are not the same, but seem to meet your needs both. -
Mass transport: how to select more than 7 roles at a time
I have about 50 roles I need to transport. I would like to use mass transport, but when I select all 50 roles, only the first 7 are actually added to the transport list.
I have to repeat the selection many times before all the roles are included in my transport request.. still a rather time consuming process. How can I select more than 7 at a time?> And now we're back to my original problem.
Oh, dear....
> We have a structured role naming convention that would make it very easy to select with wildcards.. however, when I try to do it that way, the system won't let me select more than 8 roles at a time.
This is where I think you do not have a problem but a misunderstanding. Never mind, we see those quite often.
> See if you can reproduce this problem in your environment:
I had to start it first (minisap Nw2004), renew the license and wait for the transport tool to compile. You've got me busy here on a saturday
> 1. Start PFCG
done
> 2. Utilities -> Mass Transport
yep, watched it compile.
> 3. Click multiple selection button
yep
> 4. Enter a mask that would match more than 8 roles,
yep
> press F4
NO! NO! NO! NO! NO! NO! NO! NO! NO! NO!
This is where the misunderstanding starts
> 5. Click select all (make sure more than 8 roles are selected)
No
> 6. Click copy button
No
> 7. Observe that only the first 8 role are actually copied to the multiple selection list
Instead, hit F8 where you have hit F4 and find out all roles that fit the mask will be entered into the transport.
You have mixed up the actual report selection and the search functionality of the selection screen. Play with it, it's fun.
One word of caution: Mass transport can cause perfromance problems and errors. I always try not to enter more than 500 roles into a transport at a time.
Cheers!
Jurjen -
How to select record in mulitple rows based on another field's values?
Hi,
sorry about the bad title, really not sure how to explain this
Have the following data:
Cost_center Activity_type
1005009401 CLBR0
1005009401 CLBR1
1005009401 TLBR0
1005009401 TLBR1
1005009401 VEH00
1005009402 CLBR3
1005009402 CLBR4
1005009402 TLBR5
1005009402 TLBR6
1005009402 VEH07
1005009901 CE000
1005009901 CLBR0
1005009901 CLBR1
1005009901 TLBR0
1005009901 TLBR1
1005009901 VEH01 I need to return a list of cost centers (with its associated activity types) that do not have activity types of CLBR0 and CLBR1 and TLBR0 and TLBR1 and VEH01. So in the above data, cost center 1005009401 and 1005009402 would be returned.
Any thoughts?
Thanks.
Edited by: dgouin on Aug 29, 2012 11:42 AM - added more sample data.
Edited by: dgouin on Aug 29, 2012 11:45 AM
Edited by: dgouin on Aug 29, 2012 11:49 AMSorta kludgey, but functional:
WITH ccs AS
SELECT '1005009401' AS CC, 'CLBR0' AS activity_type FROM dual
UNION ALL
SELECT '1005009401' AS CC, 'CLBR1' AS activity_type FROM dual
UNION ALL
SELECT '1005009401' AS CC, 'TLBR0' AS activity_type FROM dual
UNION ALL
SELECT '1005009401' AS CC, 'TLBR1' AS activity_type FROM dual
UNION ALL
SELECT '1005009401' AS CC, 'VEH00' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'CE000' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'CLBR0' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'CLBR1' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'TLBR0' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'TLBR1' AS activity_type FROM dual
UNION ALL
SELECT '1005009901' AS CC, 'VEH01' AS activity_type FROM dual
SELECT cc, activity_type
FROM ccs c1
WHERE 5 != (SELECT COUNT(DISTINCT activity_type)
FROM ccs c2
WHERE activity_type IN ('CLBR0','CLBR1','TLBR0','TLBR1','VEH01')
AND c1.cc = c2.cc
CC ACTIVITY_TYPE
1005009401 CLBR0
1005009401 CLBR1
1005009401 TLBR0
1005009401 TLBR1
1005009401 VEH00 -
How to select records which are added during last week
I have a scenerio in which I have a person dimension, which includes all the information about the person. I want to take two extracts out of it. One is monthly and one is on weekly basis. In the monthly I am just taking data for that particular month and then joining it with the Fact table. It is simple and I have already done it. I am having trouble for doing it on weekly basis of the current month, what I want to do is after the 1st week I want to select the new persons which were added (delta) during the 1st week. In the end of 2nd week I want to select those records which were added during 2nd week and so on for all the 4 weeks. e.g.
Day
8 The persons which were added during 1st 7th
15 The persons which were added during 8th 14th
23 The persons which were added during 15th 22nd
31 The persons which were added during 23rd 31st
Any suggestions will be appriciated please. ThanksA few steps arem required
1) when inserting or updating a record in the target table set wk and mth IND to 'N'
2) when running the week load after loading the data in the proper target end table
set the wk ind to 'N' where wk_ind = 'Y'
3) when running the month load after loading the data in the proper target end table
set the wk ind to 'N' where mth ind = 'Y'
did this help ?
DJ -
How to select records filter by the value which stored in xml field
I read many datas to solve my problem,but those doesn't work...
At first, I create a table in sqlserver
CREATE TABLE [dbo].[Demo](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Content] [xml] NOT NULL
Then I insert two records:
INSERT INTO Demo(Content) VALUES(
'<plan>
<teachers>
<teacher>1</teacher>
<teacher>2</teacher>
</teachers>
</plan>')
INSERT INTO Demo(Content) VALUES(
'<plan>
<teachers>
<teacher>3</teacher>
<teacher>4</teacher>
</teachers>
</plan>')
Now ,I want to get the records which the Content field's teacher=3. I try my best to sovle it ,but I can't.
Are there somebody can help me? Thanks !You can use the .exist method to do that. Try these:
SELECT *
FROM Demo
WHERE Content.exist('plan/teachers/teacher[. = 3]') = 1
DECLARE @teacherId INT = 3
SELECT *
FROM Demo
WHERE Content.exist('plan/teachers/teacher[. = sql:variable("@teacherId")]') = 1 -
How to select records inserted in a table in last 30 mins
I need to select the records inserted or generated in the basic scott.emp table assuming date created is a new column which inserts the time at the time of creation
select * from emp where (date_Created) between (sysdate -30/1440) and sysdate;Does the above code works or should i need to look something new
Please advise
Regards,sri wrote:
I need to select the records inserted or generated in the basic scott.emp table assuming date created is a new column which inserts the time at the time of creation
select * from emp where (date_Created) between (sysdate -30/1440) and sysdate;Does the above code works or should i need to look something new
Please advise
Regards,It would be better to say:
select * from emp where date_created >= sysdate-30/(24*60); -
How to select records from Interactive Reports based on checkboxes
Referring to the link below
http://apex.oracle.com/pls/otn/f?p=31517:95
I want to select rows from the Interactve Report based on a checkbox. This demo page has 2 sections, one for classic report and other for interactive one. The classic report is able to select the whole records but the interactive report selects only the emp nos. I am looking for a functionality where I can select the whole record from the interactive report.
Any pointers will be helpful.
ThanksThat is easy. You should just modify the query:
DECLARE
v_count INTEGER := 0;
BEGIN
:p95_text_ir := NULL;
FOR i IN 1 .. apex_application.g_f20.COUNT
LOOP
v_count := v_count + 1;
FOR c IN (SELECT ename, job, mgr, sal, deptno
FROM emp
WHERE empno = apex_application.g_f20 (i))
LOOP
:p95_text_ir :=
:p95_text_ir
|| 'ID: '
|| c.empno
|| ' / '
|| 'Name: '
|| c.ename
|| ' / '
|| 'Job: '
|| c.job
|| ' / '
|| 'Manager: '
|| c.mgr
|| ' / '
|| 'Salary: '
|| c.sal
|| ' / '
|| 'Department: '
|| c.deptno
|| CHR (10);
END LOOP;
END LOOP;
:p95_text_ir := :p95_text_ir || ' / Records selected: ' || v_count;
END;Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
How to select record like A?
Hi,
I want to select the records like "one letter + non alphabetic characters" from a table. For example: A!, B??, D2, F%5 etc.
What is the right SQL for those kind of records. I think, I should use regular expression but i couldn't find the right one. I'll be appreciated if you can send the sql statement.
Thanks
SeherI want to select the records like "one letter + non alphabetic characters" from a table. Maybe something like:
SQL> WITH test_tab AS
2 (SELECT 'A!' col_1 FROM DUAL
3 UNION ALL
4 SELECT 'A?$#' FROM DUAL
5 UNION ALL
6 SELECT 'AB&' FROM DUAL
7 UNION ALL
8 SELECT 'A123' FROM DUAL
9 UNION ALL
10 SELECT '123' FROM DUAL)
11 -- end test_data
12 SELECT col_1
13 FROM test_tab
14 /
COL_
A!
A?$#
AB& -- Discard because second letter is an alphabet
A123
123 -- Discard because first letter is a digit
5 rows selected.
SQL> WITH test_tab AS
2 (SELECT 'A!' col_1 FROM DUAL
3 UNION ALL
4 SELECT 'A?$#' FROM DUAL
5 UNION ALL
6 SELECT 'AB&' FROM DUAL
7 UNION ALL
8 SELECT 'A123' FROM DUAL
9 UNION ALL
10 SELECT '123' FROM DUAL)
11 -- end test_data
12 SELECT col_1
13 FROM test_tab
14 WHERE REGEXP_LIKE (col_1, '^[[:alpha:]][^[:alpha:]]')
15 /
COL_
A!
A?$#
A123
3 rows selected.
SQL> Regards,
Jo
Edit: Changed Query. Thanks to Sean... ;)
Edit: Removed '*$' from query. Thanks again to Sean... !http://www.mysmiley.net/imgs/smile/angel/angelnot.gif!
Sigh... I think I need to have more practice on these. -
How to select record item,vendor & quotation wise
Hi experts,
I have one quiery regarding developing a report & smartforms i hav to fetch data item wise vendor wise & quotation wise in same requirement.
thanks
ketan pande
ABAP consultant.Hi,
To get the SC item details,you an use the FM 'BBP_PD_SC_GETDETAIL".
Also to get the vendor details,you can use the FM "BBP_PARTNER_GET_PURCH_DATA_NEW".
BR,
Disha.
Pls reward points for useful answers.
Maybe you are looking for
-
Error message when trying to add signature. An error has occurred that may be fixed by installing the latest version of the Japanese Language Support package. How can I fix this? Thanks [email protected]
-
How to delink Mail and Address Book?
I do not want MAIL to use email addresses in my ADDRESS BOOK. Is there a way to "delink" MAIL and ADDRESS BOOK?
-
How do you change the header/footer color for MyPage.
I understand that you can change the type of headers and footer for Mypage using Subportals. If I want to change the 'color' of the header for mypage, do I just have to 'create a new header using a different color' or 'edit and change the color of th
-
Forms save message problem!
Um working in forms 9i. I have set SeprateFrame = True in the configuration file, so that the forms applet opens up in a new window. Now there are two BROWSER windows...one, in which user types the URL of the Forms server and Second, in which the for
-
Error message - failed to export to Microsoft Word
I signed up for this servive and it does not seem to be working for me. I have tyried different pdf files and browsers and I keep getting the same error message.