Bulk Fetch from a Cursor
Hi all,
Can you please give your comments on the code below.
we are facing an situation where the value of <cursor_name>%notfound is misleading. How we are overcoming the issue is moving the 'exit when cur_name%notfound' stmt just before the end loop.
open l_my_cur;
loop
fetch l_my_cur bulk collect
into l_details_array;
--<< control_comes_here>>
--<< l_details_array.count gives me the correct no of rows>>
exit when l_inst_cur%NOTFOUND;
--<< control never reaches here>>
--<< %notfound is true>>
--<< %notfound is false only when there are as many records fetched as the limit (if set)>>
forall i in 1 .. l_count
insert into my_table ....( .... ) values ( .... l_details_array(i) ...);
--<< This is never executed :-( >>
end loop;
Thanks,
Sunil.
Read
fetch l_my_cur bulk collect
into l_details_array; as
fetch l_my_cur bulk collect
into l_details_array LIMIT 10000;
I am trying to process 10,000 rows at a time from a possible 100,000 records.
Sunil.
Hi all,
Can you please give your comments on the code below.
we are facing an situation where the value of <cursor_name>%notfound is misleading. How we are overcoming the issue is moving the 'exit when cur_name%notfound' stmt just before the end loop.
open l_my_cur;
loop
fetch l_my_cur bulk collect
into l_details_array;
--<< control_comes_here>>
--<< l_details_array.count gives me the correct no of rows>>
exit when l_inst_cur%NOTFOUND;
--<< control never reaches here>>
--<< %notfound is true>>
--<< %notfound is false only when there are as many records fetched as the limit (if set)>>
forall i in 1 .. l_count
insert into my_table ....( .... ) values ( .... l_details_array(i) ...);
--<< This is never executed :-( >>
end loop;
Thanks,
Sunil.
Similar Messages
-
Optimal number of records to fetch from Forte Cursor
Hello everybody:
I 'd like to ask a very important question.
I opened Forte cursor with approx 1.2 million records, and now I am trying
to figure out the number of records per fetch to obtain
the acceptable performance.
To my surprise, fetching 100 records at once gave me approx 15 percent
performance gain only in comparsion
with fetching records each by each.
I haven't found significant difference in performance fetching 100, 500 or
10.000 records at once.In the same time, fetching 20.000
records at once make a performance approx 20% worse( this fact I cannot
explain).
Does anybody have any experience in how to improve performance fetching from
Forte cursor with big number of rows ?
Thank you in advance
Genady Yoffe
Software Engineer
Descartes Systems Group Inc
Waterloo On
CanadaYou can do it by writing code in start routine of your transformations.
1.If you have any specific criteria for filtering go with that and delete unwanted records.
2. If you want to load specific number of records based on count, then in start routine of the transformations loop through source package records by keeping a counter till you reach your desired count and copy those records into an internal table.
Delete records in the source package then assign the records stored in internal table to source package. -
Which method does the actual bulk fetch from database in ADF?
Hi,
I'm looking to instrument my ADF code to see where bottlenecks are. Does anyone know which method does the bulk fetch from the database so that I can override it?
Thanks
KevinHi,
I think you need to be more specific. ADF is a meta
data binding layer that delegates data queries to the
business service
FrankSorry - to be specific I probably mean BC4J - when a query runs in a view object. -
Fetching from a cursor and writing to a file in Pro*C
Hi guys,
I have a situation in hand here and I guess my "C" skills are putting me up to the test. My cursor is fetching 3 records and its all fine. I am also being able to sprintf those details and the fprintf also works perfectly -- except when I come back for Record 2, the details get overwritten and finally Record 3 is what remains on the file.
I know that UTL_FILE.PUT_LINE works just fine in Loops but here I seem to be doing somethign wrong. Has anyone seen this problem or situation before ?
void get_student_data(void)
FILE *student_file;
char student_file_name[100];
exec sql begin declare section;
exec sql end declare section;
if ((student_file = fopen(student_file_name,"w")) == NULL)
printf("Error opening data file!\n");
exec sql declare student_cur cursor for
select s.student_id
to_char(s.start_date,'DD-Mon-YYYY'),
s.student_addr1,
s.student_addr2,
s.city,
s.state,
s.zip_code
from student s
order by s.student_id;
exec sql open student_cur;
for (;;)
exec sql fetch student_cur
into :cur_student_id,
:cur_start_date,
:cur_addr1,
:cur_addr2,
:cur_city,
:cur_state,
:cur_zip_code;
if (sqlcode > 0)
break;
sprintf(out_line, "\"%d\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\","\n",
student_id,
(char *)start_date.arr,
(char *)addr1.arr,
(char *)addr2.arr,
(char *)city.arr,
(char *)state.arr,
(char *)zip_code.arr );
fprintf(student_file, out_line);
exec sql close student_cur;
if (!student_file == NULL))
fclose(student_file_file);
{code}
Thanks a bunch !
Edited by: RDonASunnyDay on Oct 20, 2009 11:07 AMHi riedelme,
The program is working fine. The procedure I am calling happens to be inside a FOR loop which I did not mention and that's my fault. You guys were on the right track.
If you notice, the fclose(filename) was at the very end of the procedure but everytime the procedure is called in the out for loop, the file gets opened and closed. So, that's why the file has always one record !
However, the logic of closing the cursor shoudl still be after closing the inner for loop.
Thanks -
Bulk Fetch From an Oracle Sequence
I am trying to get a range of sequence values from an Oracle sequence.
I am using the option as show below using query
SELECT SEQUENCE_NAME.NEXTVAL FROM SYS.DUAL CONNECT BY LEVEL <= 10.
The above SQL gets 10 sequence value.
I just wanted to to check, if the implementation below is safe in a Multi User Environment?
Is the statement show below atomic. i.e. Multi parallel execution of the same function; Would it cause any inconsistencies?
EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
BULK COLLECT INTO v_seq_list;
FUNCTION select_sequence_nextval_range(
i_quantity IN INTEGER)
RETURN INTEGER IS
o_nextval INTEGER;
v_seq_list sequence_list;
BEGIN
EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
BULK COLLECT INTO v_seq_list;
-- Get the first poid value.
o_nextval := v_seq_list(1);
RETURN o_nextval;
END select_sequence_nextval_rangeAcquire Lock
You acquire a lock on a sequence? That's news to me - please post the code that does that. I certainly hope you don' t mean you are directly accessing the SYS.SEQ$ table to lock the row for that sequence - it isn't nice to mess with Oracle's tables!
For couple of JAVA/C applications the usage of sequence number is pretty big. Could be 100,000 for one single application processing.
How does that correlate with your previous statement that you get 10 at a time?
Sequences aren't designed for use cases that require gap-free sets of numbers or for use cases that require consecutive sets of numbers.
We wanted to implement the range get of sequence using a different mechanism.
For few other applications; we just need one sequence number for the application processing. So we use the select seq.nextval to get the value. So the same sequence number needs to serve the role of giving a single value as well as a consecutive range of values.
Then you may need to consider using your own table to track the chunks that need to be allocated. You would use a scheme similar to what Greg.Spall discussed except you would keep the 'chunk' data in your own table.
I'm not talking about using your own table to control actual one-by-one sequence number generation - that is a very bad idea. But if you need to work with large ranges that are allocated infrequently there is nothing wrong with using your own function and your own table to keep track of those allocations.
The 'one by one' number generation would be handled by an actual sequence. The generation of a 'start value' and an 'end value' would be handled by accessing your custom table. Each row in that table would have 'start_value' and 'available_numbers' colulmns.
Your function would take a parameter for how many numbers you need. For just one number the function would call the sequence.nextval and return that along with a count of '1'.
For a range the function would:
1. find a row in the table with an 'available_numbers' value large enough to satisfy the request,
2. lock the row for update
3. capture the 'start_value' for return to the user
4. adjust both the 'start_value' and 'available_numbers' values to account for the range being allocated
5. update the table and commit
6. return the 'start_value' and 'number_allocated' to the user (number_allocated might be LESS than requested perhaps)
The above is a viable solution ONLY if the frequency of allocation and the size of allocation avoids the serialization issues associated with trying to allocate your own sequence numbers.
Those issues can be somewhat mitigated by having the table store multiple rows with each row having a large chunk of values that can be allocated. Then your function query can get the first 'unlocked' row and avoid serializing just because one row is currently locked. -
Bulk Fetch stored procedure.
I am new to the oracle world.
Does any one have a very good, but simple example of a bulk fetch that show the creation of the container variable?SQL> declare
2 /* Declare index-by table of records type */
3 type emp_rec_tab is table of emp%rowtype index by binary_integer;
4
5 /* Declare table variable*/
6 emptab emp_rec_tab;
7
8 /* Declare REF CURSOR variable using SYS_REFCURSOR declaration
9 in 9i and above */
10 rcur sys_refcursor;
11
12 /* Declare ordinar cursor */
13 cursor ocur is select * from emp;
14
15 begin
16
17 /* bulk fetch using implicit cursor */
18 select * bulk collect into emptab from emp;
19 dbms_output.put_line( SQL%ROWCOUNT || ' rows fetched at once from implicit cursor');
20 dbms_output.put_line('---------------------------------------------');
21
22 /* bulk fetch from Ordinar cursor */
23 open ocur;
24 fetch ocur bulk collect into emptab;
25 dbms_output.put_line( ocur%ROWCOUNT || ' rows fetched at once from ordinar cursor');
26 dbms_output.put_line('---------------------------------------------');
27 close ocur;
28
29 /* bulk fetch from Ordinar cursor using LIMIT clause */
30 open ocur;
31 loop
32 fetch ocur bulk collect into emptab limit 4;
33 dbms_output.put_line(
34 emptab.count ||
35 ' rows fetched at one iteration from ordinar cursor using limit');
36 exit when ocur%notfound;
37 end loop;
38 close ocur;
39 dbms_output.put_line('---------------------------------------------');
40
41 /* bulk fetch from ref cursor */
42 open rcur for select * from emp;
43 fetch rcur bulk collect into emptab;
44 dbms_output.put_line( rcur%ROWCOUNT || ' rows fetched at once from ref cursor');
45 dbms_output.put_line('---------------------------------------------');
46 close rcur;
47
48 /* bulk fetch from ref cursor using LIMIT clause */
49 open rcur for select * from emp;
50 loop
51 fetch rcur bulk collect into emptab limit 4;
52 dbms_output.put_line( emptab.count ||
53 ' rows fetched at one iteration from ref cursor using limit');
54 exit when rcur%notfound;
55 end loop;
56 close rcur;
57 dbms_output.put_line('---------------------------------------------');
58
59 /* bulk fetch using execute immediate */
60 execute immediate 'select * from emp' bulk collect into emptab;
61 dbms_output.put_line( SQL%ROWCOUNT || ' rows fetched using execute immediate');
62 dbms_output.put_line('---------------------------------------------');
63
64 end;
65 /
14 rows fetched at once from implicit cursor
14 rows fetched at once from ordinar cursor
4 rows fetched at one iteration from ordinar cursor using limit
4 rows fetched at one iteration from ordinar cursor using limit
4 rows fetched at one iteration from ordinar cursor using limit
2 rows fetched at one iteration from ordinar cursor using limit
14 rows fetched at once from ref cursor
4 rows fetched at one iteration from ref cursor using limit
4 rows fetched at one iteration from ref cursor using limit
4 rows fetched at one iteration from ref cursor using limit
2 rows fetched at one iteration from ref cursor using limit
14 rows fetched using execute immediate
 
PL/SQL procedure successfully completed.Rgds. -
In my Procedure I want to explicitly open the cursor and fetch from the cursor and again close the cursor
I don’t want to use like this for some testingsomething:
Create procedure kk
Cur out sys_refcursor
As
Open cur for
Select * from table;
End
I need to use like this
Create procedure kk
Cursor c is select * from table; need to return this cursor.
As
How to return that cursor
Thanksmaybe something like:
create or replace procedure get_emp_name as
cursor c1 is
select * from emp;
vEname emp.ename%type;
begin
open c1;
fetch c1 into vEname;
if c1%notfound then
exit;
end if;
close c1;
end;
/or
Create procedure get_emp_name as
Cursor c1 is
select *
from emp;
begin
for c1_rec in c1 loop
dbms_output.put_line('Emp Name: '||c1_rec.ename);
end loop;
end;
/ -
Fetch from cursor when no records returned
Hi,
I've got the following question / problem?
When I do a fetch from a cursor in my for loop and the cursor returns no record my variable 'r_item' keeps the value of the previous fetched record. Shouldn't it contain null if no record is found and I do a fetch after I closed and opend the cursor? Is there a way the clear the variable before each fetch?
Below you find an example code
CURSOR c_item (itm_id NUMBER) IS
SELECT DISTINCT col1 from table1
WHERE id = itm_id;
r_item c_item%ROWTYPE;
FOR r_get_items IN c_get_items LOOP
IF r_get_items.ENABLE = 'N' THEN
open c_item(r_get_items.ITMID);
fetch c_item into r_item;
close c_item;
IF r_item.ACCES = 'E' then
action1
ELSE
action2
END IF;
END IF;
END LOOP; ThanxDECLARE
CURSOR c_dept IS
SELECT d.deptno
, d.dname
, d.loc
, CURSOR (SELECT empno
, ename
, job
, hiredate
FROM emp e
WHERE e.deptno = d.deptno)
FROM dept d;
TYPE refcursor IS REF CURSOR;
emps refcursor;
deptno dept.deptno%TYPE;
dname dept.dname%TYPE;
empno emp.empno%TYPE;
ename emp.ename%TYPE;
job emp.job%TYPE;
hiredate emp.hiredate%TYPE;
loc dept.loc%TYPE;
BEGIN
OPEN c_dept;
LOOP
FETCH c_dept INTO deptno, dname, loc, emps;
EXIT WHEN c_dept%NOTFOUND;
DBMS_OUTPUT.put_line ('Department : ' || dname);
LOOP
FETCH emps INTO empno, ename, job, hiredate;
EXIT WHEN emps%NOTFOUND;
DBMS_OUTPUT.put_line ('-- Employee : ' || ename);
END LOOP;
END LOOP;
CLOSE c_dept;
END;
/like this... -
Bulk fetch taking long time.
I have created a procedure in which i am fetching data from remote db using database link.
I have 1 million data to fetch and the row size is around 200 bytes ( The table is having 10 attribute sizing 20 bytes each )
OPEN cur_noit;
FETCH cur_noit BULK COLLECT INTO rec_get_cur_noit;
CLOSE cur_noit;
The problem is it is taking more than 4 hours just to fetch the data.I need to know the corresponding factor and check that factor and most importantly what can be done ...like:-
1. If the DB link is slow ? how can i check the speed of DB link ?
2. I am fetching large size so is my PGA full or not used in optimized way ? How can i check the size of PGA and also increase that ? and set the optimum value.
My CPU usage seems fine.
Please let me know what else could be the reasons also ?
*I know i can use Limit clause in Bulk. Kindly let me know if it also could be the reason for my above problemCouple of more things:- I am using oracle 9i.
1.I need to transform the data also(Multiplying column value with fixed integer or setting a variable with another string,local table has couple of more attribute for which i need to fetch values from another table), so it will not be the exact replication.
2. I will not take all the rows from remote DB , i have a where clause by which i find the subset of what i want to copy.
Do you think it is achievable by below methods ?
Apologies, I am novice in this and just googled a bit about the method you suggested.So, Please ignore my noviceness
Materialzed views:-
-It is going to make a local copy of whole table there by taking space on my current DB.
-If i make a materialezed view just before starting copying what difference i would make i.e i am again first copying it from remote db and then i will be fetching from this cursor (materialezed view). I am not sure aren''t we doing more processing now i.e Using network while making materialez view + fetching from this cursor there by taking same memory as previously.
there is always a possibility of delay in refresh i.e when tuples are changed in remote DB and when i copy in my actual table from materialezed view.
Merge:-
I am using bulk collect and BULK Binding FORALL insert in my local table.Do you think this method would be faster and can solve the problem. I have explained above what i am intending to do.. -
SAVE EXCEPTIONS when fetching from cursors by BULK COLLECT possible?
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
Hello,
I'm using an Cursor's FETCH by BULK COLLECT INTO mydata...
Is it possible to SAVE EXCEPTIONS like with FORALL? Or is there any other possibility to handle exceptions during bulk-fetches?
Regards,
MartinThe cursor's SELECT-statement uses TO_DATE(juldat,'J')-function (for converting an julian date value to DATE), but some rows contain an invalid juldat-value (leading to ORA-01854).
I want to handle this "rows' exceptions" like in FORALL.
But it could also be any other (non-Oracle/self-made) function within "any" BULK instruction raising (un)wanted exceptions... how can I handle these ones?
Martin -
How to use BULK INSERT for a data from a cursor?
Oracle 10G enterprise edition.
I tried to Bulk insert datas returning from a cursor, its returning error.
PLS-00302: component 'LAST' must be declared
I need some help to use the Bulk INSERT here.Can any one help me to specify what error i have made?
CREATE OR REPLACE PROCEDURE HOT_ADMIN.get_search_keyword_stats_prc
IS
CURSOR c_get_scenarios
IS
SELECT a.*,ROWNUM rnum
FROM (
SELECT TRUNC(r.search_date) sdate,
r.search_hits hits,
r.search_type stype,
r.search_qualification qual,
r.search_location loc,
r.search_town stown,
r.search_postcode pcode,
r.search_college college,
r.search_colname colname,
r.search_text text,
r.affiliate_id affiliate,
r.search_study_mode smode,
r.location_hint hint,
r.search_posttown ptown,
COUNT(1) cnt
FROM w_search_headers r
WHERE search_text IS NOT NULL
AND NVL(search_type,' ') <> 'C'
AND TRUNC(search_date)= TO_DATE(TO_CHAR(SYSDATE-1,'DD-MON-RRRR'))
GROUP BY TRUNC(r.search_date),
r.search_hits,
r.search_type,
r.search_qualification,
r.search_location,
r.search_town,
r.search_postcode,
r.search_college,
r.search_colname,
r.search_text,
r.affiliate_id,
r.search_study_mode,
r.location_hint,
r.search_posttown
ORDER BY cnt desc
) a
WHERE ROWNUM <=1000;
lc_get_data c_get_scenarios%ROWTYPE;
BEGIN
OPEN c_get_scenarios;
FETCH c_get_scenarios into lc_get_data;
CLOSE c_get_scenarios;
FORALL i IN 1..lc_get_data.last
INSERT INTO W_SEARCH_SCENARIO_STATS VALUES ( i.sdate,
i.hits,
i.stype,
i.qual,
i.loc,
i.stown,
i.pcode,
i.college,
i.colname,
i.text,
i.affiliate,
i.smode,
i.hint,
i.ptown,
i.cnt
COMMIT;
END;This isn't what you asked, but I've generally found it helpful to list the columns in an INSERT statement before the values. It is of course optional, but useful for reference when looking at the statement later
-
Wanted to fetch data from ref cursor to nested pl/sql table getting an erro
create or replace type "DEPT12" as object(dno number(2),dname varchar2(30),loc varchar2(50));
create or replace type dept_tab as table of "DEPT12"
create or replace type "LOC12" as object(locno number,loc_name varchar2(100))
create or replace type loc_tab as table of "LOC12"
create or replace type dept_loc_rec1 as object (dept_dt dept_tab,eno number,loc_dt loc_tab);
create type dept_loc_tb as table of dept_loc_rec1
create table dept_loc_tb_bk1(dept_dt dept_tab,eno number,loc_dt loc_tab)
NESTED TABLE dept_dt
STORE AS dept_tab12,
NESTED TABLE loc_dt
STORE AS loc_tab12
insert into dept_loc_tb_bk1 values(dept_tab(dept12(3,'ABD','LOC')
,dept12(4,'ABD','LOC')
,dept12(5,'ABD','LOC')),3,loc_tab(loc12(21,'AAB'),
loc12(22,'AAB'),
loc12(23,'AAB')));
when I am trying to fetch data from ref cursor to pl/sql table which i am getting an error ora-06504: pl/sql : Return types of result set variables or query do not match.
I have created a nested table of same as the nested pl/sql object table dept_loc_tb and i have declared the lv_dept_loc_tb of same dept_loc_tb but getting an above error when trying to fetch into that variable.
Please any one who can solve my problem.
declare
type cr is ref cursor;
cr_obj cr;
lv_dept_loc_tb dept_loc_tb;
begin
open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
fetch cr_obj bulk collect into lv_dept_loc_tb;
close cr_obj;
end;Your query selects 3 separate columns therefore requires 3 collections of corresponding types. You want to treat those 3 columns as an object of DEPT_LOC_REC1 type:
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
declare
ERROR at line 1:
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
ORA-06512: at line 9
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select DEPT_LOC_REC1(dept_dt,eno,loc_dt) from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
PL/SQL procedure successfully completed.
SQL> SY.
P.S. Discover sys_refcursor. -
Hello,
I have a procedure, which specification is something like that:
procedure proc1 (pcursor OUT SYS_REFCURSOR, parg1 IN NUMBER, parg2 IN NUMBER, ...);Inside the body of proc1 I have
OPEN pcursor FOR
SELECT column1,
column2,
CURSOR (SELECT column1, column2
FROM table2
WHERE <some clauses come here>) icursor1
FROM table1
WHERE <some clauses come here>;In a PL/SQL block I would like to execute proc1 and then to fetch from pcursor. This is what I am doing so far:
DECLARE
ldata SYS_REFCURSOR;
larg1 NUMBER := 123;
larg2 NUMBER := 456;
outcolumn1 dbms_sql.Number_Table;
outcolumn2 dbms_sql.Number_Table;
BEGIN
some_package_name.proc1 (ldata, larg1, larg2, ...);
FETCH ldata BULK COLLECT INTO
outcolumn1, outcolumn2,..., *and here is my problem*;
END;
/How can I rewrite this in order to get the content of icursor1 ?
Thanks a lot!Verdi wrote:
How can I rewrite this in order to get the content of icursor1 ?
Firstly ref cursors contain no data they are not result sets but pointers to compiled SQL statements.
Re: OPEN cursor for large query
PL/SQL 101 : Understanding Ref Cursors
Ref cursors are not supposed to be used within PL/SQL or SQL for that matter, though people keep on insisting on doing this for some reason.
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm#CIHCJBJJ
Purpose of Cursor Variables
You use cursor variables to pass query result sets between PL/SQL stored subprograms and their clients. This is possible because PL/SQL and its clients share a pointer to the work area where the result set is stored.A ref cursor is supposed to be passed back to a procedural client language, such as Java or .Net.
If you want to re-use a SQL statement in multiple other PL/SQL or SQL statements you would use a view. -
Need a test for fetch into from a cursor or an alternative.
I've got a small oddity.
Ultimately it's two cursors that are exactly the same except a part of the WHERE clause. Depending on how many records I am going through (based on a counter) I need to use one cursor or the other as the outer loop, to then process an inner loop.
My problem is I don't quite know how to exit out of the current loop when the fetch reaches the end of the cursor. Meaning, in each of these loops, there's an IF THEN to see which cursor I'm using, and then fetch from the correct one. If I use a FOR X IN CURSOR loop, I'll have to double up the code, one for each outer cursor loop.
What's the test in Oracle for no record found or when it hits the end of a cursor with a fetch? Or am I stuck and I can only use the exception block when the fetch fails?
Thansk!You can check whether your fetch returned any data with %notfound.
DECLARE
l_cur sys_refcursor;
l_var VARCHAR2 (30);
BEGIN
IF TO_CHAR (SYSDATE, 'Day') = 'Monday'
THEN
OPEN l_cur FOR
SELECT dummy
FROM DUAL;
ELSE
OPEN l_cur FOR
SELECT dummy
FROM DUAL
WHERE 1 = 2;
END IF;
LOOP
FETCH l_cur
INTO l_var;
EXIT WHEN l_cur%NOTFOUND;
DBMS_OUTPUT.put_line (l_var);
END LOOP;
END;
/ -
Hello all.
How can i enforce the sql+ start fetching first cursor field by
one field intervals?
My sql+ starts fetch from the second item by 2 records intervals,
so the 4th record is the next one to fetched after the second.
best regards
yosi sarid.Hi,
could you please show us the where clause of the cursor?
I think you are missing something.
Another fault in your Code is the x_commit_count.
You increment it every time, but you never set it to zero again. So after 100 inserts, it commits after each loopstep.
Is this what you want???
DECLARE
CURSOR c_cursor IS SELECT * FROM TABLE_A@REMOTE, TABLE_B@REMOTE WHERE...
x_commit_count NUMBER := 0;
BEGIN
FOR r_record IN c_cursor LOOP
INSERT INTO LOCAL_TABLE;
x_commit_count := x_commit_count + 1;
IF x_commit_count >= 100 THEN
COMMIT;
ELSE
NULL;
END IF;
END LOOP;
END;
HTH
Detlev
Maybe you are looking for
-
Can I create separate Notes folders in Mail?
I've tried searching and have found different answers (mainly no), but I thought I would ask here before I throw in the towel. I'm wanting to create different folders in my Mail account for Notes (not mailboxes, but just a few different Notes folders
-
Why do I get Illegal Component position when I say FlowLayout.CENTER
The code runs fine if you replace the line Jp7.add(submitButton, FlowLayout.CENTER); with Jp7.add(submitButton); I know FlowLayout's default location is CENTER. But when I explicitly say to center the button, it crashes during runtime but compiles fi
-
Photoshop Elements 8 - Web Photo Gallery?
I have Photoshop Elements 8 trial edition and Photoshop Elements 2.0. I would like to create a Web Photo Gallery with Photoshop Elements 8 trial edition just like I have been doing with Photoshop Elements 2.0. I cannot find how to create a Web Phot
-
Where are the buttons gone File upload and Download in New ABAP Editor
Where are the buttons gone of File upload and Download in New ABAP Editor in ECC 6.0. Or some new utility added for this feature. Kindly guide. Thanks, pradeep
-
List of BlackBerry's And Specs?
Hey everyone, Im writing a technical report for one of my school programs, and I have chosen to write about how BlackBerry's have advanced through the years. I was wondering if there was a good place to find older phone specs, i.e. processor power, r