存储过程的递归限制0

时间:2018-09-06 11:25:30

标签: c# mysql

当我尝试在c#中调用存储过程时。返回:

  

常规delete_medikalislem超出了递归限制0(由max_sp_recursion_depth变量设置)

delete_medikalislem过程:

DELETE FROM medikal WHERE islem_id = p_id;

存储的参数: 名称:p_id,类型:VARCHAR,长度:25

       using (MySqlConnection connect = new MySqlConnection(connectionString))
           {
             using (MySqlCommand cmd = new MySqlCommand(mw.db_name+ ".delete_medikalislem", connect))
                 {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("p_id", mw.medikalislem[0]);
                    connect.Open();
                    cmd.ExecuteNonQuery();
                    connect.Close();
                 }
            }

我在删除后使用触发器:

BEGIN

DECLARE tl_ integer default 0;
DECLARE usd_ integer default 0;
DECLARE eur_ integer default 0;
DECLARE gbp_ integer default 0;
DECLARE toplam_ integer default 0;

SELECT tl, usd, eur, gbp INTO tl_, usd_, eur_, gbp_ FROM medikalfirmalar WHERE isim = OLD.medikal_isim;
DELETE FROM medikal_caritahsilat WHERE islem_id = OLD.islem_id;
    IF (OLD.birim='TL') THEN
    SET toplam_= tl_ - OLD.tutar;
    UPDATE medikalfirmalar SET tl = toplam_ WHERE isim = OLD.medikal_isim;
    END IF;
    IF (OLD.birim='USD') THEN
    SET toplam_= usd_ - OLD.tutar;
    UPDATE medikalfirmalar SET usd = toplam_ WHERE isim = OLD.medikal_isim;
    END IF;
    IF (OLD.birim='EUR') THEN
    SET toplam_= eur_ - OLD.tutar;
    UPDATE medikalfirmalar SET eur = toplam_ WHERE isim = OLD.medikal_isim;
    END IF;
    IF (OLD.birim='GBP') THEN
    SET toplam_= gbp_ - OLD.tutar;
    UPDATE medikalfirmalar SET gbp = toplam_ WHERE isim = OLD.medikal_isim;
    END IF;
END

我该如何解决?

1 个答案:

答案 0 :(得分:1)

这只是SQL在抱怨递归性。您必须明确地告诉它递归可以扩展到多少层。 Add SET max_sp_recursion_depth=255在您的过程开始时