Search code examples
sqloracle-databasestored-proceduressql-delete

Oracle delete procedure is not working correctly


This is my oracle stored procedure. I want to delete certain id when I pass data to procedure, but when I perform this proc. I get deleted everything that my trable has.

Can someone please check this out

CREATE OR REPLACE PROCEDURE Delete(
    id IN number)

AS
BEGIN
        DELETE FROM Users WHERE Users.id_user= id;
END;
/

I have tried to put :

DELETE FROM Users WHERE Users.id_user == id;

Then I get compilation error.


Solution

  • Have you tried DELETE FROM Users WHERE id_user = id; ?

    Using == is not valid SQL for an equality check.

    I still don't see why are you getting all rows deleted. DELETE FROM Users WHERE Users.id_user = id should be working properly.

    More information on the DELETE STATEMENT syntax.