Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unique Constraint and Db link error in Stored Procedure

User_19BPUAug 5 2016 — edited Aug 8 2016

Hi,

I am using a Stored Procedure to do an insert or update based on a customer Id which I fetch from the table, I am also using a DB link to read the records another DB in the procedure like below:-

select custId into cust_id from customer@CUST_LINK where sapContact= 'xxx'

if custid is null then

// insert

else

//update

But I am getting the below error when I execute the procedure :-

Error occured at -1ORA-00001: unique constraint (CUSTOMER_P) violated

ORA-02063: preceding line from CUST_LINK

What is the issue where, the DB link is working fine when i invoke it separately (outside SP). Why unique constraint error is thrown as we have check for both insert and update (like we use the merge statement)? also whether we can catch the unique constraint exception in Exception block of SP? Please clarify.

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2016
Added on Aug 5 2016
8 comments
1,497 views