why null ? i have to update that row if unique contraint is founded
Main Topics
Browse All TopicsNo idea how to manipulate ORA-00001: unique constraint with pl/sql this is my script :
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Why is not working whis :
CREATE OR REPLACE PROCEDURE TABLE_UPDATE
IS
duplicate_info EXCEPTION;
PRAGMA EXCEPTION_INIT (duplicate_info, -00001);
loop...
begin
insert stm...
EXCEPTION
WHEN duplicate_info THEN
UPDATE MYTABLE SET
"REGDATE" = rec.REGDATE,
"ORIGIN" = rec.ORIGIN
// My constraint
WHERE "DOMAIN" = rec.DOMAIN
AND "USERNAME" = rec.USERNAME ;
END LOOP;
END;
Its looks like syntax error - im not an expert doing this :)
In your code you've not the proper structure for a PL/SQL block (you are missing and END statement). Should be as below. Also, you don't need to define you're own exception, ORA-00001 is already defined for you in PL/SQL (in the SYS.STANDARD package) as DUP_VAL_ON_INDEX. So the following should work ...
Thanks for answer me so quick but im still got errors , may be its some thing wrong befor i call EXCEPTION ? this is the all sql statment to create procedure .
CREATE OR REPLACE PROCEDURE "SOME_WORD"."UPDATE_TABL
BEGIN
FOR rec IN (SELECT * FROM MY_ORIGINAL_TABLE where rownum<='2')
LOOP
INSERT INTO MYTABLE
(
"REGDATE",
"USERNAME",
"DOMAIN",
"OPTLETTER",
"IP",
"FIRSTNAME",
"LASTNAME",
"STATE",
"ZIP",
"COUNTRY",
"BDATE"
)
VALUES (
rec.REGDATE,
rec.USERNAME,
rec.DOMAIN,
rec.OPTLETTER,
rec.IP,
rec.FIRSTNAME,
rec.LASTNAME,
rec.STATE,
rec.ZIP,
rec.COUNTRY,
rec.BDATE
);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
UPDATE MYTABLE SET
"REGDATE" = rec.REGDATE,
"ORIGIN" = rec.ORIGIN
WHERE "DOMAIN" = rec.DOMAIN
AND "USERNAME" = rec.USERNAME ;
END ;
END LOOP;
COMMIT ;
END;
<code sanitized by AnnieMod, Cleanup Admin>
ORA-06550: line 31, column 10:
PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the
following:
begin case declare end exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
ORA-06550: line 39, column 9:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
;
ORA-06550: line 41, column 4:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
following:
pragma
Business Accounts
Answer for Membership
by: HainKurtPosted on 2009-08-10 at 10:39:48ID: 25062102
put an exception block
loop...
begin
insert stm...
exception
when others
then null;
end;
end loop;