0

CODE :-

CREATE OR REPLACE TRIGGER user_address_check
BEFORE INSERT OR UPDATE ON street_master
FOR EACH ROW
BEGIN
DECLARE check INT;
check = STRCMP(street_master.locality_name,NEW.name);
if(check!=1)
then dbms_output.put_line('Record Already Exists');
End IF;
END;

street_master name of the table , locality_name of the column

-what i am trying to achieve

-compare each row of the column locality_name which has string(some address) stored in it with locality_name which i am about to insert ...so if there is a possible duplicate i should be notified

Should I use 'LIKE' instead of STRCMP ...if yes then how..?

Error i got after executing

1064 - Erreur de syntaxe près de 'TRIGGER user_address_check

BEFORE INSERT OR UPDATE ON street_master FOR EACH R' Ã la ligne 1

5
  • There is no create or replace trigger ... command in MySQL. Drop the trigger then recreate it. See this question. Commented Mar 8, 2016 at 8:44
  • Then just use create trigger. Commented Mar 8, 2016 at 8:47
  • Read what I am trying to achieve .. first line is not what i want to fix... :| Commented Mar 8, 2016 at 8:52
  • 1
    Why do you say that? That's exactly what your error message states. Also, this seems to be a trigger that just implements a unique constraint on the table street_master. If this is what you're trying to do, just use a proper constraint. Commented Mar 8, 2016 at 8:57
  • If you don't like constraints then you can create trigger with this answer: stackoverflow.com/a/18621419/2253302 Commented Mar 8, 2016 at 9:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.