Issue a commit statement for every 10000 rows updated
Hi,
I have a update statement, updating huge number of records.
I wanted to issue a commit statement for every 10000 rows updated.
Can this be done?
Thanks,
Dinesh
user522952 wrote:
Hi,
I have a update statement, updating huge number of records.
I wanted to issue a commit statement for every 10000 rows updated.
Can this be done?
Thanks,
Dinesh Why do you want to issue commit statement frequently? Do you have a possible reason?
If you think it will improve performance, you are 200% wrong. It will not improve performance it will only degrade performance. It will destroy the integrity of your data. It will screw you up big time.
Ever heard of [ORA-01555 Snapshot too old|http://asktom.oracle.com/pls/asktom/f?p=100:11:4217554330904383::::P11_QUESTION_ID:275215756923] error? Your approach has a likely chance of getting that too.
Do it in a single UPDATE. How big the table is does not matter. Do it in a single update, Oracle is fully capable of doing it.
Similar Messages
-
Sequence number - increment one for every 3 rows
Dear All,
I want to get a sequence number /group number, which increments 1 for every 3 rows.
For Example:
Seq Name
1 a
1 b
1 c
2 D
2 E
2 F
3 G
3 H
3 I
4 abc
4 aaa
4 bbb
Is there a function to do this?Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Did you read the header of this forum?? But besides being rude, you are also ignorant. A table has no ordering, so
there is no concept of every third row. What are you using for a sort key? What happens when a new row is added to or deleted from this table?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Sql statement for retrieving the last update time of a table
Hello all,
Can somebody give me an example of sql statement for retrieving the last update time of an oracle table.
Thank you
IlThanks for the fast replies. It works great when I test it as a sql statement but when trying to populate a datalist with it it raises the following exception:
Exception Details: System.ArgumentException: SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN is neither a DataColumn nor a DataRelation for table DefaultView
Part of the Datalist Code:
ItemTemplate>
Line 12: SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN)):
Line 13: <asp:Label ID="SCN_TO_TIMESTAMP_MAX_ORA_ROWSCN__Label" runat="server" Text='<%# Eval("[SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN))]") %>'>
Line 14: </asp:Label><br/>
Line 15: <br/>
{code}
Why is this happening? Any ideas?
Il -
I'm getting probelms with the following procedure. Is there any that I can do to commit after every 10,000 rows of deletion? Or is there any other alternative! The DBAs are not willing to increase the undo tablespace value!
create or replace procedure delete_rows(v_days number)
is
l_sql_stmt varchar2(32767) := 'DELETE TABLE_NAME WHERE ROWID IN (SELECT ROWID FROM TABLE_NAME W
where_cond VARCHAR2(32767);
begin
where_cond := 'DATE_THRESHOLD < (sysdate - '|| v_days ||' )) ';
l_sql_stmt := l_sql_stmt ||where_cond;
IF v_days IS NOT NULL THEN
EXECUTE IMMEDIATE l_sql_stmt;
END IF;
end;I think I can use cursors and for every 10,000 %ROWCOUNT, I can commit, but even before posting the thread, I feel i will get bounces! ;-)
Please help me out in this!
Cheers
Sarma!Hello
In the event that you can't persuede the DBA to configure the database properly, Why not just use rownum?
SQL> CREATE TABLE dt_test_delete AS SELECT object_id, object_name, last_ddl_time FROM dba_objects;
Table created.
SQL>
SQL> select count(*) from dt_test_delete WHERE last_ddl_time < SYSDATE - 100;
COUNT(*)
35726
SQL>
SQL> DECLARE
2
3 ln_DelSize NUMBER := 10000;
4 ln_DelCount NUMBER;
5
6 BEGIN
7
8 LOOP
9
10 DELETE
11 FROM
12 dt_test_delete
13 WHERE
14 last_ddl_time < SYSDATE - 100
15 AND
16 rownum <= ln_DelSize;
17
18 ln_DelCount := SQL%ROWCOUNT;
19
20 dbms_output.put_line(ln_DelCount);
21
22 EXIT WHEN ln_DelCount = 0;
23
24 COMMIT;
25
26 END LOOP;
27
28 END;
29 /
10000
10000
10000
5726
0
PL/SQL procedure successfully completed.
SQL>HTH
David
Message was edited by:
david_tyler -
Commit statement for selected row
Hello,
I am working on an OAF page where there is a table region.
This table region is connected to a VO and the VO to a EO.
I have connected it to a EO because the user should be able to enter data directly to the table.
I have given a single save button at the bottom so that on clicking it, it takes to a handler function in my AM.
In the handler function, I getAllFetchedRows in an array and then one by one I perform checks and then save by calling getOADBTransaction.commit after doing vo.setAttribute( ) with the corrected values.
Now my problem is that while saving I am using the same EO being used in the above table. So even though I want to save line by line after performing checks programatically, the moment getOADBTransaction.commit is called for the first row, all the rows gets saved without even going through the checks.
Is there any other way of calling the commit so that it saves only the passed row and not all the rows.
Regards
HawkerHi Gyan,
I have done exactly like that. At first I fetch what the users have entered and then validate it and then I do setAttribute with the correct value.
And after looping for all the rows I finally commit.
I was initially thinking that if I set the attribute for one row and if I go to the next row the data in the earlier row would get lost.
But it has now worked nicey.
Regards -
Airport issue.. drops down for every 5 min (Approximately)
im using a wireless network to connect to internet..
router is working fine..around every 5 min the strenghts go down to zero.. if i switch off the airport and switch it on again.. the bar shows full strength.. which confirms that there is no problem with the router..
so for every 5 min.. i restarting the airport.. what would be the problem?Sorry, can't help you with this, but there are numerous threads regarding this issue with a variety of suggestions on how it may be addressed. You might give a few of those a try and see if any works, although it'll most likely be a shot in the dark. Mine has had this problem since the evening of the day I bought it in January and no fix has worked yet. I went back to the 1990s and wired ethernet. It's an issue which Apple has to know about, but has not resolved.
-
How to make the shade for every other row?
Hi,
i want the rows in my report dispalyed as:
row1: gray
row2: white
row3: gray
row4: white
row5: gray
thanxHello,
Highlight every alternate row
Highlight every alternate row
Regards -
How to tune the Update statement for 20 million rows
Hi,
I want to update 20 million rows of a table. I wrote the PL/SQL code like this:
DECLARE
v1
v2
cursor C1 is
select ....
BEGIN
Open C1;
loop
fetch C1 bulk collect into v1,v2 LIMIT 1000
exit when C1%NOTFOUND;
forall i in v1.first..v1.last
update /*+INDEX(tab indx)*/....
end loop;
commit;
close C1;
END;
The above code took 24 mins to update 100k records, so for around 20 million records it will take 4800 mins (80 hrs).
How can I tune the code further ? Will a simple Update statement, instead of PL/SQL make the update faster ?
Will adding few more hints help ?
Thanks for your suggestions.
Regards,
Yogini JoshiHello
You have implemented this update in the slowest possible way. Cursor FOR loops should be absolute last resort. If you post the SQL in your cursor there is a very good chance we can re-code it to be a single update statement with a subquery which will be the fastest possible way to run this. Please remember to use the {noformat}{noformat} tags before and after your code so the formatting is preserved.
David -
Performance Issue in Select Statement (For All Entries)
Hello,
I have a report where i have two select statement
First Select Statement:
Select A B C P Q R
from T1 into Table it_t1
where ....
Internal Table it_t1 is populated with 359801 entries through this select statement.
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
Can this code be optimized?
Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
Regards,If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
Use a Select within Select.
First Select Statement:
Select A B C P Q R package size 5000
from T1 into Table it_t1
where ....
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
do processing........
endselect
This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
Thanks,
Juwin -
Issue on Payment statement for customer
Hi,
I am not sure what is the customer payment statement process.
Now I have a scenario:
One sales order have one sold -to party ,one ship-to party,one bill-to party, one payer and one payment statement receiver with partner function.
As I known,the payment just relate to the payer,it means the payment statement will show the payer,then how can I get the right payment statement receiver information on the payment statement from SAP system automatically?
When should we send the payment statement to the customer? Before system payment or after system payment? Just want to confirm.
Thanks for any confirmation.
Best Regards,
DonHi Sadashivan,
It seems this solution meets my requirement. we need to create a new form for printout,is it right?
Here I still have some concerns:
What is the data extraction logic for the SAP script for the new form?
Due to my request is base on sale order instead of the customer code,it means one customer code(payer) maybe have many of dunning document receiver(we will put it in the partner view of sale order),but for each sales order,it is one-to-one (one payer VS one dunning document receiver). but as you known the dunning program just taking the customer open items instead of Sales order,then how can I find out the relationship between customer open items and the corresponding sale order?
Anyway,many thanks.
Best regards,
Don -
Do CIF BAdIs issue implicit COMMIT WORKS (for FM's called "in update task")
I am calling the CIF BAdI:
/SAPAPO/TR_TRANSFER.
In the PUSH_LANE_DATA method of this BAdI, I want to call a function module "in update task".
To trigger the actual execution of this function module, do I have to code an explicit COMMIT WORK in the BAdI or will SAP automatically generate a COMMIT WORK when the BAdI ends?Hope you have called the FM correctly with the additional importing parameter , also check if your FM is RFC enabled then check the "pass by value" option.
-
Error when trying to issue a grant statement for Scott's emp table
I'm trying to complete a lab assignment in which we have to grant the select on Scott's emp table. Here is the statement I used. I'm wondering why did i receive the error that the table doesn't exist.
SQL> GRANT SELECT ON SCOTT.EMP TO DEV;
GRANT SELECT ON SCOTT.EMP TO DEV
ERROR at line 1:
ORA-00942: table or view does not exist
Edited by: user566571 on Dec 4, 2009 8:19 AMAre you the owner of the emp table ? If not then
Do the user(which you are using to grant the privilege) has GRANT ANY PRIVILEGE or GRANT ANY OBJECT PRIVILEGE privileges ?
Do the user has been granted the appropriate privileges on the SCOTT.EMP WITH GRANT option ?
To grant the privileges to the role, first your user should have those privileges and that with the option to grant to others using WITH GRANT. -
Commit for every 1000 records in Insert into select statment
Hi I've the following INSERT into SELECT statement .
The SELECT statement (which has joins ) has around 6 crores fo data . I need to insert that data into another table.
Please suggest me the best way to do that .
I'm using the INSERT into SELECT statement , but i want to use commit statement for every 1000 records .
How can i achieve this ..
insert into emp_dept_master
select e.ename ,d.dname ,e.empno ,e.empno ,e.sal
from emp e , dept d
where e.deptno = d.deptno ------ how to use commit for every 1000 records .ThanksSmile wrote:
Hi I've the following INSERT into SELECT statement .
The SELECT statement (which has joins ) has around 6 crores fo data . I need to insert that data into another table.Does the another table already have records or its empty?
If its empty then you can drop it and create it as
create your_another_table
as
<your select statement that return 60000000 records>
Please suggest me the best way to do that .
I'm using the INSERT into SELECT statement , but i want to use commit statement for every 1000 records .That is not the best way. Frequent commit may lead to ORA-1555 error
[url http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:275215756923]A nice artical from ASKTOM on this one
How can i achieve this ..
insert into emp_dept_master
select e.ename ,d.dname ,e.empno ,e.empno ,e.sal
from emp e , dept d
where e.deptno = d.deptno ------ how to use commit for every 1000 records .
It depends on the reason behind you wanting to split your transaction into small chunks. Most of the time there is no good reason for that.
If you are tying to imporve performance by doing so then you are wrong it will only degrade the performance.
To improve the performance you can use APPEND hint in insert, you can try PARALLEL DML and If you are in 11g and above you can use [url http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_parallel_ex.htm#CHDIJACH]DBMS_PARALLEL_EXECUTE to break your insert into chunks and run it in parallel.
So if you can tell the actual objective we could offer some help. -
Hi
Iam inserting around 2.5 mmillion records in aconversion project
let me know how i can commit after every 10000 rows please can u tell me whether i can use bulk insert or bulk bind because i have never used please resolve my problem.
Thanks
Madhuas sundar said, per link of TOM you are better of not commiting in th loop other wise it will give you snapshot too old error,
still if you want
1. set the counter to 0. ct number:=0;
increment counter in the loop ct:=ct+1;
IF ct=10000 THEN
COMMIT;
END IF;
2. you can use bulk collect and FORALL also. and commit.
but still follow the tread as per TOM
typo
Message was edited by:
devmiral -
Hello to all
Please I need help for th folowing question:
WITH some_data AS (
SELECT 'CNDMNL75P65L736C' cf,'' cp ,'' cr, 0 as I1, 1 as I2, 0 as I3 FROM dual
UNION ALL
SELECT 'PNZGCM74M24L736C' ,'' cp ,'' cr, 5, 0, 0 FROM dual
UNION ALL
SELECT '' , '' cp ,'1' cr, 675,0, 0 FROM dual
UNION ALL
SELECT '' , '027113850273' cp ,'' cr, 0 ,32, 0 FROM dual
UNION ALL
SELECT '' , '12298850273' cp ,'' cr, 2, 0 ,0 FROM dual
UNION ALL
SELECT '' , '35798850273' cp ,'' cr, 0, 12 ,0 FROM dual
UNION ALL
SELECT '' , '627771888273' cp ,'' cr, 10, 2 ,0 FROM dual
UNION ALL
SELECT 'XDZGCM74M22L736C' ,'' cp ,'' cr, 15, 0, 10 FROM dual
select * from some_data;
CF
CP
CR
I1 I2 I3
CNDMNL75P65L736C
0 1 0
PNZGCM74M24L736C
5 0 0
1
675 0 0
027113850273
0 32 0
12298850273
2 0 0
35798850273
0 12 0
627771888273
10 2 0
XDZGCM74M22L736C
15 0 10
How can I get a something as; one(only) record for every 3 rows, like this
CNDMNL75P65L736C 0 1 0PNZGCM74M24L736C 5 0 0 1 675 0 0 (first 3 rows)
027113850273 0 32 0 12298850273 2 0 0 35798850273 0 12 0 (next 3 rows, )
627771888273 10 2 0 XDZGCM74M22L736C 15 0 10 (and so on )
Thanks in advanceFor version 11g:
WITH some_data AS (
SELECT 'CNDMNL75P65L736C' cf,'' cp ,'' cr, 0 as I1, 1 as I2, 0 as I3 FROM dual
UNION ALL
SELECT 'PNZGCM74M24L736C' ,'' cp ,'' cr, 5, 0, 0 FROM dual
UNION ALL
SELECT '' , '' cp ,'1' cr, 675,0, 0 FROM dual
UNION ALL
SELECT '' , '027113850273' cp ,'' cr, 0 ,32, 0 FROM dual
UNION ALL
SELECT '' , '12298850273' cp ,'' cr, 2, 0 ,0 FROM dual
UNION ALL
SELECT '' , '35798850273' cp ,'' cr, 0, 12 ,0 FROM dual
UNION ALL
SELECT '' , '627771888273' cp ,'' cr, 10, 2 ,0 FROM dual
UNION ALL
SELECT 'XDZGCM74M22L736C' ,'' cp ,'' cr, 15, 0, 10 FROM dual
select * from (
select a.*, mod(rownum-1,3)+1 rn, ceil(rownum/3) grp from some_data a
pivot(max(cf) cf, max(cp) cp, max(cr) cr, max(i1) i1, max(i2) i2, max(i3) i3
for rn in (1 a,2 b,3 c));
GRP
A_CF
A_CP
A_CR
A_I1
A_I2
A_I3
B_CF
B_CP
B_CR
B_I1
B_I2
B_I3
C_CF
C_CP
C_CR
C_I1
C_I2
C_I3
1
CNDMNL75P65L736C
0
1
0
PNZGCM74M24L736C
5
0
0
1
675
0
0
2
027113850273
0
32
0
12298850273
2
0
0
35798850273
0
12
0
3
627771888273
10
2
0
XDZGCM74M22L736C
15
0
10
For version 12c:
WITH some_data AS (
SELECT 'CNDMNL75P65L736C' cf,'' cp ,'' cr, 0 as I1, 1 as I2, 0 as I3 FROM dual
UNION ALL
SELECT 'PNZGCM74M24L736C' ,'' cp ,'' cr, 5, 0, 0 FROM dual
UNION ALL
SELECT '' , '' cp ,'1' cr, 675,0, 0 FROM dual
UNION ALL
SELECT '' , '027113850273' cp ,'' cr, 0 ,32, 0 FROM dual
UNION ALL
SELECT '' , '12298850273' cp ,'' cr, 2, 0 ,0 FROM dual
UNION ALL
SELECT '' , '35798850273' cp ,'' cr, 0, 12 ,0 FROM dual
UNION ALL
SELECT '' , '627771888273' cp ,'' cr, 10, 2 ,0 FROM dual
UNION ALL
SELECT 'XDZGCM74M22L736C' ,'' cp ,'' cr, 15, 0, 10 FROM dual
select * from some_data
match_recognize(
measures a.cf acf, a.cp acp, a.cr acr, a.i1 ai1, a.i2 ai2, a.i3 ai3,
b.cf bcf, b.cp bcp, b.cr bcr, b.i1 bi1, b.i2 bi2, b.i3 bi3,
c.cf ccf, c.cp ccp, c.cr ccr, c.i1 ci1, c.i2 ci2, c.i3 ci3
pattern (a b{0,1} c{0,1})
define a as 1=1, b as 1=1, c as 1=1
ACF
ACP
ACR
AI1
AI2
AI3
BCF
BCP
BCR
BI1
BI2
BI3
CCF
CCP
CCR
CI1
CI2
CI3
CNDMNL75P65L736C
0
1
0
PNZGCM74M24L736C
5
0
0
1
675
0
0
027113850273
0
32
0
12298850273
2
0
0
35798850273
0
12
0
627771888273
10
2
0
XDZGCM74M22L736C
15
0
10
Maybe you are looking for
-
Approval Authorization for Sales Order
Dear Experts, Can anybody help me by providing a user query for Approval templete for the following condition. The system should prevent the sales order & Delivery when the customer is having one oustanding invoice above 90 days and the balance due f
-
Where do we declare surcharges and in which table it gets stored
Hi Guys, Where do we assign surcharges for customers and for the material level. Please reply ASAP. Cheers Raj
-
Software Report - How to clean it up?
Hi guys, I just came up with the following query to get the list of software (in Add/Remove Programs) installed in All Systems collection and based on a certain string contained in the client's hostname. Declare @CollID char(8) Set @CollID = 'XXX0000
-
I have imported a CD into my itunes, but itunes cant find album artwork and it wont sync the album to my iphone. Help!!
-
Autocorrect improvement suggestions (the bubble with the tiny "x")
The autocorrect programming does not make sense. When a "corrected word" is suggested, it pops up in a little bubble above the word. That's fine. The problem is that the ONLY way to cancel the autocorrect is by hitting that infuriatingly tiny littl