samedi 30 janvier 2021

creating a procedure in mysql to check if a record exist and update if it does exist

ITS GIVING ME THIS ERROR NEAR UPDATE QUERY I REALLY DONT KNOW WHY??? HELP

CREATE PROCEDURE insertandupdate()
BEGIN
    if exists (SELECT * from roleprivillges as rp WHERE (rp.roleID=1 AND rp.priviligesID=1) LIMIT 1) then
    BEGIN
       UPDATE `roleprivillges` SET `IsActive`=0 WHERE roleID=1 AND priviligesID=1;                                            
    END;
    else
    BEGIN
        INSERT INTO roleprivillges('roleID','priviligesID','IsActive') VALUES('1','1','1');
    END;    
    end if;
END 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 5

Aucun commentaire:

Enregistrer un commentaire