Home » SQL & PL/SQL » SQL & PL/SQL » Procidure includ not duplicate
Procidure includ not duplicate [message #653385] Mon, 04 July 2016 08:58 Go to next message
rkled
Messages: 1
Registered: July 2016
Junior Member
Please, help me on this cod.
I need to implement a procedure that inserts data into a table, if you mistake for 'AG' existing, will return an error with the description that I put in the exception.

create or replace PROCEDURE MY_PROC_01
(
T_DATA VARCHAR2,
T_NAME VARCHAR2,
T_TURN VARCHAR2,
T_AG VARCHAR2
)

IS
BEGIN
INSERT INTO TESTETAB (DATA, NOME, TURNO, ID, ALGO) VALUES (T_DATA, T_NAME, T_TURN, TESTTAB_SEQ.nextval,T_AG);
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
DBMS_OUTPUT.PUT_LINE('ERRO!');
END;
Thanks!!
Re: Procidure includ not duplicate [message #653386 is a reply to message #653385] Mon, 04 July 2016 09:04 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to the forum.

Please read our OraFAQ Forum Guide and please read How to use [code] tags and make your code easier to read
Re: Procidure includ not duplicate [message #653387 is a reply to message #653385] Mon, 04 July 2016 09:05 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

Does the code above not do what you want already?
Re: Procidure includ not duplicate [message #653391 is a reply to message #653385] Mon, 04 July 2016 09:29 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Your code works only if you have a UNIQUE constraint on AG.
Is this what you want? Or must the constraint be more complex, like with other columns.

Previous Topic: Updating Status W to A
Next Topic: Constraints in External Table.
Goto Forum:
  


Current Time: Fri Apr 19 19:01:10 CDT 2024