Oracle deadlocks on delete statement
I had a package procedure that deletes from a inline-view. It worked well and didn't create any database locks, looked like this:
PROCEDURE serverdisconnect(pCode1 NUMERIC, pCode2 NUMERIC) IS
BEGIN
DELETE FROM
SELECT cl.* FROM CurrentLogins cl, Accounts a
WHERE cl.Code1 = pCode1
AND cl.Code2 = pCode2
AND cl.Code = a.code
AND a.Type = 'lplayer'
ORDER BY a.code
COMMIT;
END serverdisconnect;I slightly changed the procedure to look like following, and deadlocks started to come:
PROCEDURE ServerDisconnect(pCode1 NUMERIC, pCode2 NUMERIC, pChannelServerCode CurrentLogins.ChannelServerCode%TYPE, pDeleteList OUT cursor_type)
IS
vDeleteList sys.ODCINumberList;
BEGIN
DELETE FROM
SELECT cl.* FROM CurrentLogins cl, Accounts a
WHERE cl.Code1 = pCode1
AND cl.Code2 = pCode2
AND cl.Code = a.code
AND cl.ChannelServerCode = pChannelServerCode
AND cl.Code = a.code
AND a.Type = 'lplayer'
) RETURNING Code
BULK COLLECT INTO vDeleteList;
OPEN pDeleteList FOR
SELECT * FROM TABLE(vDeleteList);
COMMIT;
END ServerDisconnect;As you see the main difference in the delete statement is that i removed "ORDER BY"-clause? Can really such data ordering plays a role with dead locking? Does the data records be always ordered with ORDER-BY-clause same way always to avoid deadlock? Why i started to get deadlock after changing the procedure?
I have Oracle 10g.
Yes, typo, i fixed initial post now.
Delete will be technically done on table CurrentLogins, using that inline-view.
I will move the Commit to proper place as you suggested.
but still i don't understand why deadlocks started to occure.
Maybe really the answer is having "order by" clause, which solves the deadlocks?
See this link:
http://www.oracle-base.com/articles/misc/Deadlocks.php
>
To resolve the issue, make sure that rows in tables are always locked in the same order.
>
Does it says that i always have to have "order by" sentence included into my delete statement?
Relationships between tables:
alter table CURRENTLOGINS
add constraint FK_CURRENTLOGINS_ACCOUNTS foreign key (CODE)
references ACCOUNTS (CODE);Maybe ORDER-BY really solves deadlocks then, see:
http://www.dbasupport.com/forums/archive/index.php/t-50438.html
>
Add an explicit ORDER BY to the select, and it will probably go away.
>
Edited by: CharlesRoos on Sep 9, 2010 6:05 AM
Similar Messages
-
Problem : SQL Server Delete Statement vs Oracle Delete Statement
Hi,
I am currently involved in a SQL Server - Oracle Migration effort and I have hit a roadblock on one of the queries.
I have created two tables named DUMMY and DUMMY1 in MSDE with the same structure :-
CREATE TABLE DUMMY
CLIENT_ID INT,
NME VARCHAR(80),
BATCH_ID INT,
CATALOG_NAME VARCHAR(50),
DATA_SOURCE VARCHAR(50)
GOI have a DELETE statement that deletes from the two tables, by selecting common data using Joins:-
DELETE DUMMY
FROM DUMMY src
JOIN
DUMMY1 dst
ON
src.batch_id = dst.batch_id
AND src.catalog_name = dst.catalog_name
AND src.data_source = dst.data_source
WHERE
src.batch_id = 1
AND src.catalog_name = '1'
AND src.data_source = '1'Now, I have created the same Tables ( DUMMY and DUMMY1 ) in Oracle :-
CREATE TABLE DUMMY
CLIENT_ID NUMBER(5),
NME VARCHAR2(80),
BATCH_ID NUMBER(10),
CATALOG_NAME VARCHAR2(50),
DATA_SOURCE VARCHAR2(50)
)I have written a Delete statement to mimic the fucntionality in this manner :-
DELETE FROM
DUMMY
WHERE
client_id,
nme,
batch_id,
catalog_name,
data_source
IN
SELECT *
FROM
DUMMY src
JOIN
DUMMY1 dst
ON
src.batch_id = dst.batch_id
AND src.catalog_name = dst.catalog_name
AND src.data_source = dst.data_source
WHERE
src.batch_id = 1
AND src.catalog_name= '1'
AND src.data_source = '1'
)However, I keep getting this error whe I try to test it :-
ORA-06550: line 1, column 89:
PL/SQL: ORA-00913: too many values
Can you please help me modify the query to simulate the same functionality as the orignial SQL Server Query ?
Thanks,
SandeepThere is probably a mismatch between the number of columns.
Try this * Not Tested *
DELETE FROM
DUMMY
WHERE
client_id,
nme,
batch_id,
catalog_name,
data_source
IN
SELECT src.client_id,
src.nme,
src.batch_id,
src.catalog_name,
src.data_source
FROM
DUMMY src
JOIN
DUMMY1 dst
ON
src.batch_id = dst.batch_id
AND src.catalog_name = dst.catalog_name
AND src.data_source = dst.data_source
WHERE
src.batch_id = 1
AND src.catalog_name= '1'
AND src.data_source = '1'
); -
Deadlock when deleting from rsstatmanpsa during DSO activation
We are experiencing intermittent Oracle deadlocks during DSO activation in our BI system. The deadlocks occur when the following SQL statement is executed:
delete from rsstatmanpsa where
partnr >= l_s_status-rnr_sid and
psa = l_s_status-dta.
This is at line 83 of the SET STATUS method of class CL_RSSM_STATMAN. (See below for runtime error details.)
When these errors occur the background job for the DSO activation is cancelled with the message ABAP/4 processor: DBIF_RSQL_SQL_ERROR. Strangely, when this occurs as part of a process chain, the status of the process variant does not get updated until/unless someone displays the process chain log, at which point the status changes and follow-on events are triggered. In other words, the process chain does not seem to be receiving word that the DSO activation process has abended, so we do not receive alerts that a problem has occurred.
Has anyone else experienced this issue?
Thanks,
Bob
P.S. We are running BI 7.0, Patch Level 15 on Oracle 10.2.0.4.0
Runtime Errors DBIF_RSQL_SQL_ERROR
Exception CX_SY_OPEN_SQL_DB
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "SET_STATUS" "(METHOD)", nor was it propagated by a RAISING clause.
How to correct the error
Database error text........: "ORA-00060: deadlock detected while waiting for
resource"
Internal call code.........: "[RSQL/DELE/RSSTATMANPSA ]"
Please check the entries in the system log (Transaction SM21).
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
"CL_RSSM_STATMAN===============CP" or "CL_RSSM_STATMAN===============CM008"
"SET_STATUS"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
The exception must either be prevented, caught within proedure
"SET_STATUS" "(METHOD)", or its possible occurrence must be declared in the
RAISING clause of the procedure.
To prevent the exception, note the following:
Information on where terminated
Termination occurred in the ABAP program "CL_RSSM_STATMAN===============CP" -
in "SET_STATUS".
The main program was "RSPROCESS ".
In the source code you have the termination point in line 83
of the (Include) program "CL_RSSM_STATMAN===============CM008".
The program "CL_RSSM_STATMAN===============CP" was started as a background job.
Job Name....... "BI_PROCESS_ODSACTIVAT"
Job Initiator.. "ALEREMOTE"
Job Number..... 05302800
The termination is caused because exception "CX_SY_OPEN_SQL_DB" occurred in
procedure "SET_STATUS" "(METHOD)", but it was neither handled locally nor
declared
in the RAISING clause of its signature.
The procedure is in program "CL_RSSM_STATMAN===============CP "; its source
code begins in line
1 of the (Include program "CL_RSSM_STATMAN===============CM008 ".
Source Code Extract
Line
SourceCde
53
if i_with_internal_check is initial.
54
l_s_status = i_s_status.
55
call function 'RSSM_GET_TIME'
56
importing
57
e_timestamps = l_s_status-ts_last_changed.
58
if l_s_status-ts_proc_started <= '10000101000000'.
59
l_s_status-ts_proc_started = l_s_status-ts_last_changed.
60
endif.
61
if l_s_status_exist is initial.
62
insert rsstatmanstatus from l_s_status.
63
if sy-subrc <> 0.
64
message x000.
65
endif.
66
else.
67
modify rsstatmanstatus from l_s_status.
68
if sy-subrc <> 0.
69
message x000.
70
endif.
71
endif.
72
delete from rsstatmanpart where
73
rnr = l_s_status-rnr and
74
dta = l_s_status-dta and
75
dta_type = l_s_status-dta_type.
76
select single * from rsstatmanpsa into l_s_psa where
77
rnr = l_s_status-rnr and
78
psa = l_s_status-dta.
79
if sy-subrc = 0.
80
delete from rsmdatastate_psa where
81
psa = l_s_status-dta and
82
type = l_s_status-dta_type.
>>>>>
delete from rsstatmanpsa where
84
partnr >= l_s_status-rnr_sid and
85
psa = l_s_status-dta.
86
else.
87
select single * from rsmdatastate_psa into l_ds_psa where
88
psa = l_s_status-dta and
89
type = l_s_status-dta_type.
90
if sy-subrc = 0 and l_ds_psa-sid_checked > l_s_status-rnr_sid.
91
delete from rsmdatastate_psa where
92
psa = l_s_status-dta and
93
type = l_s_status-dta_type.
94
delete from rsstatmanpsa where
95
partnr >= l_s_status-rnr_sid and
96
psa = l_s_status-dta.
97
endif.
98
endif.
99
if i_with_commit = 'X'.
100
call function 'DB_COMMIT'.
101
endif.
102
endif.Walter,
Thanks for the suggestion. This is the same recommendation I just received from SAP.
We are currently in the midst of regression testing for a major release, so cannot implement these corrections immediately. I'll post again after we implement the corrections and let you know if they solve our problem.
Thanks again.
Bob -
Delete Statement Exception Handling
Hi guys,
I have a problem in my procedure. There are 3 parameters that I am passing into the procedure. I am matching these parameters to those in the table to delete one record at a time.
For example if I would like to delete the record with the values ('900682',3,'29-JUL-2008') as parameters, it deletes the record from the table but then again when I execute it with the same parameters it should show me an error message but it again says 'Deleted the Transcript Request.....' Can you please help me with this?
PROCEDURE p_delete_szptpsr_1 (p_shttran_id IN saturn.shttran.shttran_id%TYPE,
p_shttran_seq_no IN saturn.shttran.shttran_seq_no%TYPE,
p_shttran_request_date IN saturn.shttran.shttran_request_date%TYPE) IS
BEGIN
DELETE FROM saturn.shttran
WHERE shttran.shttran_id = p_shttran_id
and shttran.shttran_seq_no = p_shttran_seq_no
and trunc(shttran_request_date) = trunc(p_shttran_request_date);
DBMS_OUTPUT.PUT_LINE('Deleted the Transcript Request Seq No (' || p_shttran_seq_no || ') of the Student (' || p_shttran_id ||') for the requested date of (' || p_shttran_request_date ||')');
COMMIT;
EXCEPTION WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Error: The supplied Notre Dame Student ID = (' || p_shttran_id ||
'), Transcript Request No = (' || p_shttran_seq_no || '), Request Date = (' || p_shttran_request_date || ') was not found.');
END p_delete_szptpsr_1;
Should I have a SELECT statement to use NO_DATA_FOUND ???A DELETE statement that deletes no rows (just like an UPDATE statement that updates no rows) is not an error to Oracle. Oracle won't throw any exception.
If you want your code to throw an exception, you'll need to write that logic. You could throw a NO_DATA_FOUND exception yourself, i.e.
IF( SQL%ROWCOUNT = 0 )
THEN
RAISE no_data_found;
END IF;If you are just going to catch the exception, though, you could just embed whatever code you would use to handle the exception in your IF statement, i.e.
IF( SQL%ROWCOUNT = 0 )
THEN
<<do something about the exception>>
END IF;In your original code, your exception handler is just a DBMS_OUTPUT statement. That is incredibly dangerous in real production code. You are relying on the fact that the client has enabled output, that the client has allocated a large enough buffer, that the user is going to see the message, and that the procedure will never be called from any piece of code that would ever care if it succeeded or failed. There are vanishingly few situations where those are safe things to rely on.
Justin -
Delete statement that uses a sub-select with the statement in the cursor
Hi all,
How to write write a delete statement that uses a sub-select with the statement in the cursor?
CURSOR excluded_dates IS
SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
INTO my_current_date_time
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'DATE_TIME'
AND report_parameters.report_parameter_name = 'EXCLUDED_DATE';
OPEN excluded_dates;
LOOP
FETCH excluded_dates INTO my_excluded_date;
EXIT WHEN excluded_dates%NOTFOUND;
DELETE FROM edr_rpt_tmp_inclusion_table
WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
END LOOP;
CLOSE excluded_dates;ThanksHi,
In such case I think is better to create a view an perform the delete using it. Example (using HR schema):
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> create or replace view v_employees as select * from employees where first_name like 'J%';
View created
SQL> select * from v_employees;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
110 John Chen JCHEN 515.124.4269 28/09/1997 FI_ACCOUNT 8200,00 108 100
112 Jose Manuel Urman JMURMAN 515.124.4469 07/03/1998 FI_ACCOUNT 7800,00 108 100
125 Julia Nayer JNAYER 650.124.1214 16/07/1997 ST_CLERK 3200,00 120 50
127 James Landry JLANDRY 650.124.1334 14/01/1999 ST_CLERK 2400,00 120 50
131 James Marlow JAMRLOW 650.124.7234 16/02/1997 ST_CLERK 2500,00 121 50
133 Jason Mallin JMALLIN 650.127.1934 14/06/1996 ST_CLERK 3300,00 122 50
139 John Seo JSEO 650.121.2019 12/02/1998 ST_CLERK 2700,00 123 50
140 Joshua Patel JPATEL 650.121.1834 06/04/1998 ST_CLERK 2500,00 123 50
145 John Russell JRUSSEL 011.44.1344.429268 01/10/1996 SA_MAN 14000,00 0,40 100 80
156 Janette King JKING 011.44.1345.429268 30/01/1996 SA_REP 10000,00 0,35 146 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24/03/1998 SA_REP 8600,00 0,20 149 80
177 Jack Livingston JLIVINGS 011.44.1644.429264 23/04/1998 SA_REP 8400,00 0,20 149 80
181 Jean Fleaur JFLEAUR 650.507.9877 23/02/1998 SH_CLERK 3100,00 120 50
186 Julia Dellinger JDELLING 650.509.3876 24/06/1998 SH_CLERK 3400,00 121 50
189 Jennifer Dilly JDILLY 650.505.2876 13/08/1997 SH_CLERK 3600,00 122 50
200 Jennifer Whalen JWHALEN 515.123.4444 17/09/1987 AD_ASST 4400,00 101 10
16 rows selected
SQL> delete from v_employees where hire_date >= to_date('01/06/1998', 'dd/mm/yyyy');
2 rows deleted
SQL> regards, -
Converting a delete statement using VPD policies and context
Hello,
I'm trying to convert a delete statement in a update statement using VPD policies and context.
+/* Supose the user 'user1' already exists. This is an application user */+
conn user1/pwd
create table user1.test_a (
id number(4),
description varchar2(100),
deleted number(1)
+);+
alter table user1.test_a add constraint test_a_pk primary key (id);
insert into user1.test_a (1, 'abc', 0);
insert into user1.test_a (2, 'def', 0);
commit;
I'd like to convert each physical deletion into a logical deletion: statements like "delete from user1.test_a where id = 1" must be converted into "update user1.test_a set deleted = 1 where id = 1".
I've found the following way: I will create a policy to avoid physical deletion. Additionally, the policy function should update the deletion flag too.
conn user1/pwd
+/* Create context package */+
create or replace package user1.pkg_security_context is
procedure p_set_ctx(
i_test_a_id in user1.test_a.id %type
+);+
end;
+/+
create or replace package body user1.pkg_security_context is
procedure p_set_ctx (
i_test_a_id in user1.test_a.id %type
+) is+
begin
dbms_session.set_context( 'user1_ctx', 'test_a_id', i_test_a_id );
end;
end;
+/+
show errors
+/* Create trigger to set the context before deletion */+
create or replace trigger user1.test_a_bef_trg
before delete on user1.test_a
for each row
declare
pragma autonomous_transaction;
begin
-- only commits the preceding update, not the delete that fired the trigger.
commit;
user1.pkg_security_context.p_set_ctx( :old.id );
end;
+/+
show errors
create context user1_ctx using user1.pkg_security_context;
+/* Policy function */+
create or replace function user1.f_policy_chk_dels (
object_schema in varchar2,
object_name in varchar2
+) return varchar2+
is
out_string varchar2(400) default '1=2 ';
+/*+
* out_string is the return value.
* - 'WHERE 1=2' means 'nothing to access'
begin
if ( loc_logged_usr_authorized > 0 ) then
+/*+
* Set the flag deleted to 1
update user1.test_a set deleted = 1 where id = sys_context( 'user1_ctx', 'test_a_id' );
out_string := out_string || 'or 1=1 ';
end if;
return out_string;
end;
+/+
show errors
+/*+
* Create policy
begin
dbms_rls.add_policy(
object_schema => 'user1' ,
object_name => 'test_a' ,
policy_name => 'policy_chk_dels' ,
function_schema => 'user1' , -- function schema
policy_function => 'f_policy_chk_dels' , -- policy function
statement_types => 'DELETE'
+);+
end;
+/+
When I try to delete a record of the table test_a:
conn user1/pwd
SQL> delete from ilogdia.oplsimulaciones sim where sim.id = 9999;
+0 rows deleted+
No rows has been deleted, but the update stmt does not work. That means, the "deleted" flag has not been updated.
Any ideas?
Thank you in advance.
Marco A. Serrano
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:43 AMThe policy function is applied once per statement execution. The policy function executes first and the UPDATE statement, presumably, updates no rows because the context is not yet populated. The row-level populates the context (I'm assuming that your session can even see context values populated by an autonomous transaction-- I would guess it could but I'd have to test that) after the UPDATE statement is already complete. The COMMIT in the row-level trigger is also pointless-- it only applies to changes made by the current autonomous transaction, of which there are none-- it cannot apply to changes made in other autonomous transactions. Declaring the row-level trigger to use autonomous transactions doesn't seem to accomplish anything other than to open the question of whether the values set in the context by the autonomous transaction are visible in the caller's transaction.
Even if this, somehow, did work, using autonomous transactions would be a very bad idea since Oracle is free to roll-back a partially executed statement (and the work done by its triggers) and re-execute it. Oracle does that with some regularity to maintain write consistency.
Justin -
Problems with StoredProcedures that use INSERT/DELETE statements
Hello
I am using Hyperion Intelligence explorer 8.5, and the database source is a MS SQL Server 2000 source connected via ODBC.
I have this problem: when I use, in a Query section, a stored procedure that (in its code) uses only SELECT statements I get the result of the query in the Results section, but when I use a storedprocedure that does some work (and executes INSERT or DELETE or other SQL statements) and ends executing a SELECT statement in order to return data to the caller Hyperion hangs.
I mean: first I select the stored procedure (Query\StoredProcedure... menù, than I start it using the Process command in Hyperion.
If the storedproc contains only SELECT statements I get the results, but if it contains INSERT or DELETE (and the last statement is a SELECT) Hyperion does not return any data and if I try to repeat the Process command I get an error that tells "the connection is busy with results from another hstmt".
Before you ask me if the stored procedure works correctly, I can confirm this because the storedproc was tested and returns the correct data if used with the db manager application.
Any suggestions? Did you ever use (successfully )storedprocedures that process data (by INSERT or DELETE statements) and then return the result with a SELECT statement?
Thank you for your helpHi Chris,
Could you please tell us in which version of IR
Hyperion is not going to support Stored
Procedures....
Regards,
ManmohanManmohan,
Did you even read what I just wrote? This is NOT happening. Stroed Procedures are an important part of the Intelligence Product, Oracle is continuing to enhance and support this functionality. I work for Oracle, I worked for Hyperion, and for Brio before that, so believe me when I tell you this.
Chris (whoever he is) is gving out incorrect information in this regard. His suggestion of the workaround for the original issue is completely accurate, but as I added, it was in issue that has been corrected as of 8.5 Service Pack 2, so even the workaround is not required as long as you've upgraded. (Note that some versions of 9.x also will require the workaround due to the timing of the releases overlapping.)
Thanks.
Larry Johnson -
Delete statements are taking longer time
Hi All,
I have an issue with delete statement. below are my oracle DB details.
SQL>select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for Linux: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
I have a schema in the database which has 120 tables in it. The problem is, when the QA team is deleting the customers from customer table, it is running long time and haven't completed. this customer table have FK relation with other tables and have all the right indexes in place. then i have tried to identified the problem, why it is taking long time, and found that when they are running this delete query at the same time application is also running. the sessions created by application are locked most of the table and at the same time the delete session is also waiting for exclusive lock on those table. I given the same info to QA team and asked to stop the application when they deleting the customers. Then they said, they don't want to stop the application and the delete has to work and they asked for different solution. Here i am not sure, what solution i need to provide them.
Can you please suggest me a approach and Thanks in advance.Hari wrote:
and at the same time the delete session is also waiting for exclusive lock on those table. The only way the delete session could be waiting for an exclusive lock on the table is if the code to delete from the customer includes the command: lock table customer in exclusive mode;Unless your original description is wrong, either the deletion code has to change or the application has to stop modifying the customer table.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
Author: <b><em>Oracle Core</em></b> -
DELETE Statement takes long time running
Hi,
DELETE statements take a very long time to complete.
Can you advice me how can I diagnostic the slow performance
ThanksDeleting rows can be an expensive operation.
Oracle stores entire row as the 'before image' of deleted information (table and index data) in
rollback segments, generates redo (keeps archiver busy), updates free lists for blocks that are
falling below PCTUSED setting etc..
Select count(*) runs longer because oracle scans all blocks (upto the High Water Mark) whether
there are or are not any rows in the blocks.
These operations will take more and more time, if the tables are loaded with APPEND hint or
SQL*Loader using direct mode.
A long time ago, I ran into a similar situation. Data was "deleted" selectively, SQL*Loader was
used (in DIRECT mode) to add new rows to the table. I had a few tables using more number of blocks
than the number of rows in the table!
Needless to say, the process was changed to truncate tables after exporting/extracting required
data first, and then loading the data back. Worked much better. -
Hello All,
Scenario BW to ORACLE
I have to write a JDBC delete statement and then insert in two message mappings
This is to delete the table records before inserting
And in the interface determination, maintain order time and give the order delete first and then insert
These are all done and in the receiver CC, I have unchecked key tags mandatory. and concurrence 10
Now, I am getting an error "unique constraint violation when executed the interface
Any idea what does this error means and this error comes under delete interface execution and the insert interface portion is on hold status in message monitoring of RWB
thx
mikeHi Mike,
The error you are getting cannot be generated from DELETE statement.This error is given by oracle when an UPDATE or INSERT statement attempted to insert a duplicate key. For Trusted Oracle configured in DBMS MAC mode, you may see this message if a duplicate entry exists at a different level.
you have to either remove the unique restriction or do not insert the key.
This means insert operation is taking place before DELETE. You need to prevent that.
Regards
Anupam -
I have question about dml mechanism. particularly delete statement
HI,
I have question about dml mechanism. particularly delete statement
I learned that SQL statements deal with each row. For example, SELECT statement insert each record(1 row) which matched with term of WHERE into record pool.
Also I find that UPDATE, INSERT statement insert each record into memory and if that is commited, I/O is generated with disk.
if so, Do DELETE statements deal with each row which is matched with terms WHERE statements? ortherwise with rownum?
I hope that I know the mechanism of DELETE statement?
If the content above which I mentioned is fault, plz point out.
Thank you for reading this contents.Hi,
leave_for wrote:
HI,
I have question about dml mechanism. particularly delete statement
I learned that SQL statements deal with each row. I'm not sure what you mean.
SQL statements deal with sets of rows ; there may be 0, 1, 2, 3 or more rows in the set.
For example, SELECT statement insert each record(1 row) which matched with term of WHERE into record pool.You must mean an INSERT or MERGE statement that includes a query. A plain old SELECT statement doesn't insert anything, or change any table in any way.
Also I find that UPDATE, INSERT statement insert each record into memory and if that is commited, I/O is generated with disk.That's right. All DML involves some I/O. The I/O may be buffered, so that the DML statement might finish before any disk I/O is actually performed.
if so, Do DELETE statements deal with each row which is matched with terms WHERE statements? ortherwise with rownum?
I hope that I know the mechanism of DELETE statement?Sorry; the last couple of lines you wrote are especially confusing.
When you have a DELETE statement that includes a WHERE clause, such as
DELETE emp
WHERE deptno = 20;then the set of rows that will be deleted is the same set of rows for which the condition "deptno = 20" is TRUE. Again, that may be 1 row, but if it is, that's mere coincidence. The number of rows in the set may be 0, or it may be 2 or more.
If ROWNUM is part of the WHERE clause, then ROWNUM will be considered when Oracle decides which rows to delete; if ROWNUM is not part of the WHERE clause, then ROWNUM will play no part in determining which rows are deleted. Remember, as Damorgan mentioned above, ROWNUM is an arbitrary number. There is no built-in order to the rows in any table. -
Prallel query and Delete statements
Hi Gurus, need your help in understanding parallel execution
We are noticing that delete statements are executing very slowly when parallel query is forced. Is this expected?
All the literature that I read says that parallel query has no impact on DML statements. Yet, the query plan on the delete statement shows that it will be executed in parallel mode. This could mean that the scan portion is happening in parallel but the delete operation itself is happening in serial, correct?
I tested in various servers and multiple tables before posting my question here. They all seem to show consistent results. Delete statements are twice slower when parallel query is forced. The same happens when parallel degree is set in table definition.
For your information, we are running 10g on windows server with 15 million rows in table, 5 million rows being deleted with the statement. There is one index on the table and it doesn’t match the columns in query. Query plan shows full table scan. Table is not portioned.
Thanks for your help in advanceParallel DML is supported by Oracle. Obviously when enabled, it can impact a DML statement.. (what literature have you read that said otherwise?)
The delete operation itself is done in parallel using rowid ranges (e.g. each PQ slave process does a distinct physical "piece" of the table).
Parallel DML should typically speed up the process. Why? Because I/O itself has latency. The process needs to wait (idle CPU time) for the I/O operation to complete before continuing.
So let's assume the process can only do a 100 deletes per second. The actual I/O channel is capable of a 1000 I/O's per second. But due to inherant latency, the "max delete speed limit" for a procces is a 100 I/O's per second. The full capacity of the I/O channel is thus not used (and cannot be used by a single process).
Parallel Query enables more processes to do I/O in order to utilise this "max speed limit".
Why would you see a degradation in performance? It could be due to overutilising the I/O channels (attempting to go faster than the speed limit so to say).
It could be due to some other contention in Oracle or even the o/s. You will need to investigate the wait state and events of the PQ processes to try and determine the probable cause. -
*** 2003-12-25 01:02:42.782
*** SESSION ID:(12.3) 2003-12-25 01:02:42.732
DEADLOCK DETECTED
No current SQL statement being executed.
The following deadlock is not an ORACLE error. It is a
deadlock due to user error in the design of an application
or from issuing incorrect ad-hoc SQL. The following
information may aid in determining the deadlock:
Deadlock graph:
---------Blocker(s)-------- ---------Waiter(s)---------
I have an application causing an Oracle deadlock with the following trace/dump. The app uses a single transaction to insert a record (containing a blob col) and then select it for update to use the blob col ref to add the blob value. Transaction commit/rollback is explicit after success/failure.
My question is, given that the trace file indicates the same process/session for the waiter and the blocker, can a single running app instance w/a single session and transaction, block itself? if so, what conditions produce such a deadlock...
Thanks for any help,
-Dean Palamides
Resource Name process session holds waits process session holds waits
TX-00010016-00000882 12 12 X 12 12 S
session 12: DID 0001-000C-00000002 session 12: DID 0001-000C-00000002
Rows waited on:
Session 12: obj - rowid = 00003152 - AAAAAAAADAAD45hAAA
(dictionary objn - 12626, file - 3, block - 1019489, slot - 0)
Information on the OTHER waiting sessions:
End of information on OTHER waiting sessions.Hi Dean:
We've had a similar problem (but doesn't manifest consistently), also single-thread, via JDBC "thin" onto Oracle 9.2.0.1.0... there's a MetaLink note, 130214.1, that shows the same symptom with Oracle 8.0 when MAX_TRANS of the LOB index is too low. I suspect in our case the INI_TRANS is too low (at 2), but LOB index storage parameters cannot be set in Orcle 9 - it's automatic.
Were you using JDBC? Is the problem the same when you use PL/SQL's DBMS_LOB.xxx procedures? What Oracle version do you have? Was it BLOB or CLOB? Is the failure consistent?
If I get any joy from Oracle support, I'll post it here... please let me know any particulars you have (such as above) about your problem. -
FORALL bulk delete statement requires lot of time even for 10 rows deletion
Hi,
when I execute FORALL bulk delete statement it requires lot of time even for 10 rows deletion.so how to avoid this problem? I checked SGA_TARGET and PGA_TARGET cureent_size and max_size are same for both. Is their memory problem?
I execute following code
DECLARE
TYPE t_id_tab IS TABLE OF test.c1%TYPE;
l_id_tab t_id_tab := t_id_tab();
Begin
select c1 bulk collect into l_id_tab from TEST where c1<=10;
dbms_output.put_line(DBMS_UTILITY.get_time);
FORALL i IN l_id_tab.first .. l_id_tab.last
delete from TEST where c1= l_id_tab(i);
dbms_output.put_line(DBMS_UTILITY.get_time);
commit;
End;
thanks in advance
Vaibhav
Edited by: Vaibhav on Oct 10, 2011 10:47 PMhi
i am working on oracle 11g. Actually i have to test which is the faster method to delete 150000 records.
1st by using FOR Loop bunch of 10000 records
2nd by using FORALL delete
kindly find below FORALL delete code
DECLARE
TYPE t_id_tab IS TABLE OF test.c1%TYPE;
l_id_tab t_id_tab := t_id_tab();
Begin
select c1 bulk collect into l_id_tab from TEST where c1<=10;
dbms_output.put_line(DBMS_UTILITY.get_time);
FORALL i IN l_id_tab.first .. l_id_tab.last
delete from TEST where c1= l_id_tab(i);
dbms_output.put_line(DBMS_UTILITY.get_time);
commit;
End;
Edited by: Vaibhav on Oct 10, 2011 10:56 PM -
Finding Delete statement issued in particular object
Dear All,
Please let me know how to find what are all the delete statement issued against a object in oracle. some one is deleted some data from one table i want to find when the delete statement fired in my schema.
With Regards
Rameshyou have audit turn on right? there should be a report for DML in audit vault.
Maybe you are looking for
-
Does migration to CUCM 8.6 to 9.1 requires aditional Money?
Hi pals! We just completed migration to CUCM 8.6 a year ago, we are now (we want to) moving to 9.1, we have a question, if it requires aditional money $$$$ (license), por for upgrade or just a minor patch. Also. Does it also requires CUC 9.1? Does it
-
Upgraded to Maverick. Can't use my mighty mouse
Using an IMac desktop. Upgraded to Maverick. Can't use my mighty mouse anymore. Bought a trackpad, hate it. It is so touchy....constantly opening any window I scroll over. Any suggestions on another mouse that is compatible?
-
Error in exchange server try again later
Hi, I have a nokia E71(firmware 200.21.118) sync with an exchange server 2003 using mail-for-exhange 2.9.158. on the nokia. i can sync mail and contacts but if put thumbnails (photo) in contact i always get the error : "error in exchange server try
-
Help - BC Putting %EF%BF%BD in between all characters in catalog names
The automatic urls for catalogs created by BC now have this "%EF%BF%BD" inbetween each character I have in the catalogue name. This breaks all the links. The only think I have worked on today is putting images in to the blog - so I don't see how that
-
I am getting below error, when I am trying to generate EJBs for Weblogic by using the BEA wlappc ant task, can any one help me out, please Error Message:- <Error> <J2EE> <BEA-160197> <Unable to load descriptor ../ejb-jar.xml of module ejb. The error