简体   繁体   中英

Delete Stored Procedure not working in SQL

I'm trying to create a stored procedure for deleting a record in my table.

I have tried the following but it doesn't seem to work:

Delimiter //
CREATE PROCEDURE BIRD_STRIKE_INCIDENT_DELETE  @row text
AS 
BEGIN
    DELETE FORM bird_strike.incidents WHERE row_names = @row
END
 delimiter ; 
 
 Call BIRD_STRIKE_INCIDENT_DELETE('11')

Can someone provide pointers on what I might be doing wrong here?

Thanks!

Your code looks more like SQL Server than MySql

This should be so

Delimiter //
CREATE PROCEDURE BIRD_STRIKE_INCIDENT_DELETE  (_row text)
BEGIN
    DELETE FROM bird_strike.incidents WHERE row_names = _row;
END//
delimiter ; 

You can consider this approach.

IF EXISTS(SELECT 1 FROM sys.procedures 
          WHERE Name = 'BIRD_STRIKE_INCIDENT_DELETE')
BEGIN
    DROP PROCEDURE dbo.BIRD_STRIKE_INCIDENT_DELETE;
END;
else
BEGIN
      CREATE PROCEDURE BIRD_STRIKE_INCIDENT_DELETE  (_row text)
      BEGIN
         DELETE FROM bird_strike.incidents WHERE row_names = _row;
      END
END;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM