简体   繁体   English

删除存储过程在 SQL 中不起作用

[英]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您的代码看起来更像 SQL Server 而不是 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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