gpt4 book ai didi

mysql存储过程语法错误

转载 作者:行者123 更新时间:2023-11-29 09:23:16 25 4
gpt4 key购买 nike

好的,这只是我编写的第二个存储过程。我想你会明白的,我正在尝试关闭信用额度以及所有发票、费用、票据等。但我收到语法错误。目标是调用 close_account_proc(398985994)

DELIMITER $$

CREATE
PROCEDURE `cc`.`close_account_proc`(cid INT)
@uid_usr := uid_usr FROM credit_acc WHERE type_acc = 'init' AND credit_used_acc = cid;
UPDATE credit_acc SET status_acc = 'closed', void_date_acc = NOW() WHERE credit_used_acc = cid;
UPDATE payment_acc SET status_acc = 'voided', void_date_acc = NOW() WHERE creditid_acc = cid;
UPDATE sbal_sbl SET status_sbl = 'voided', void_date_sbl = NOW() WHERE credit_used_acc = cid;
INSERT INTO notes_not SET uid_usr = @uid_usr, initials_not = 'SYS',status_not = 'complete', date_not = NOW(), text_not = 'Closed credit line '.cid;
UPDATE invoices_inv SET status_inv = 'voided', void_date_inv = NOW() WHERE credit_used_acc = cid;
BEGIN
END$$

DELIMITER ;

所以,无论如何,我收到此错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 5 行的 '@uid_usr := uid_usr from Credit_acc where type_acc = 'init' and Credit_used_acc ' 附近使用的正确语法。

有什么想法吗?

最佳答案

DELIMITER $$

CREATE PROCEDURE `cc`.`close_account_proc`(cid INT)
BEGIN
/* Check that it's what you wanted */
SELECT uid_usr
INTO @uid_usr
FROM credit_acc
WHERE type_acc = 'init'
AND credit_used_acc = cid;

UPDATE credit_acc SET status_acc = 'closed', void_date_acc = NOW() WHERE credit_used_acc = cid;
UPDATE payment_acc SET status_acc = 'voided', void_date_acc = NOW() WHERE creditid_acc = cid;
UPDATE sbal_sbl SET status_sbl = 'voided', void_date_sbl = NOW() WHERE credit_used_acc = cid;

/* Check that it's what you wanted */

INSERT
INTO notes_not (uid_usr, initials_not, status_not, date_not, text_not)
VALUES (@uid_usr, 'SYS', 'complete', NOW(), CONCAT('Closed credit line ', cid));

UPDATE invoices_inv SET status_inv = 'voided', void_date_inv = NOW() WHERE credit_used_acc = cid;
END
$$

DELIMITER ;

关于mysql存储过程语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/753331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com