+ Reply to Thread
Results 1 to 2 of 2

Thread: [Urgent, HELP!]Using Trigger to check duplicate

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    1

    Exclamation [Urgent, HELP!]Using Trigger to check duplicate

    Hi! I'm new in using Trigger for my database. I am currently using MySQL 5.0 Query Browser and i would like to create trigger within the browser. Here's my code

    Code:
    CREATE TRIGGER check_OrderID BEFORE INSERT ON DELIVERY
    FOR EACH ROW
    BEGIN
    	IF(orderID!=NEW.OrderID)
    	THEN
    		INSERT INTO DELIVERY(DeliveryID,OrderID,DriverID,DeliveryVID)
    		VALUES(NEW.DeliveryID,NEW.OrderID,NEW.DriverID,NEW.DeliveryVID);
    END;
    Actually I want to check if the OrderID to be inserted is already in the Delivery table, then that insertion is to ba aborted, if not, it will just continue with the insertion.

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    1

    Default

    I'm sure this is going to disapoint you. I was when i realised this.

    But in Mysql 5.0 you cannot insert or delete a row in the same table that the trigger is set on.

    Wich is wath you are doing on the table DELIVERY.

    It's MySql conseptors made it that way to avoid Stack overflow.

    The same goes for Stored procedures that can't call themself

    Sorry

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts