Successfully processed row count. [message #55438] |
Fri, 24 January 2003 06:03 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Shankaran
Messages: 3 Registered: January 2003
|
Junior Member |
|
|
This is my problem.
I am updating the empid column of the table emp
as
update table emp
set empid = new_empid;
somewhere it comes up with the primary key constraint error.
Can I narrow down on the problematic row JUST by looking at the error variables populated by Oracle server.
(I dont want to write a query to find the problematic row. Is there any way out without writing a query to findout the problematic row)
Kindly help me out...
|
|
|
|
|
Re: Successfully processed row count. [message #55451 is a reply to message #55449] |
Fri, 24 January 2003 07:26 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Shankaran
Messages: 3 Registered: January 2003
|
Junior Member |
|
|
say there are totally 25 rows in the table. For the first 20 rows empid=new_empid works perfectly fine.while trying to update the 21st row it causes the violation.
Now how do I find out the the number of rows successfully updated(b4 causing the violation, in our case 20) OR How do I find out that particular row(say rowid, or the new_empid,empid value) which caused the violation.
|
|
|
Re: Successfully processed row count. [message #55454 is a reply to message #55449] |
Fri, 24 January 2003 08:10 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/42800.jpg) |
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
--
-- stored procedure takes 2 input.
-- empid to be updated and newempid
--
mag@itloaner1_local > create or replace procedure sp_test345 (oldempid in number,
2 newempid in number)
3 as
4 begin
5 update test345 set empid=newempid where empid=oldempid;
6 commit;
7 exception
8 when dup_val_on_index then
9 raise_application_error(-20000,'the empid '||newempid||' already exists');
10 end;
11 /
Procedure created.
--
-- inserting sample rows sequentially from 1 to 25
--
mag@itloaner1_local > begin
2 for mag in 1..25 loop
3 insert into test345 values (mag);
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
--
-- updating using proceudre
-- empid 3 is updated to 5.
-- empid 5 already exists..so error is displayed.
mag@itloaner1_local > exec sp_test345(3,5);
BEGIN sp_test345(3,5); END;
*
ERROR at line 1:
ORA-20000: the empid 5 already exists
ORA-06512: at "MAG.SP_TEST345", line 9
ORA-06512: at line 1
--
-- empid 26 does not exist.
--
mag@itloaner1_local > exec sp_test345(3,26);
PL/SQL procedure successfully completed.
|
|
|