gpt4 book ai didi

mysql - 为什么 mySQL 过程在从过程内部调用时返回 null,但在单独调用时则不返回 null

转载 作者:行者123 更新时间:2023-11-29 18:33:54 24 4
gpt4 key购买 nike

我有一个 mySQL 过程,它正在调用另一个过程来构建串联的 TEXT 字段。当调用外部过程时,我的插入语句给出“脚本不能为空”错误。当我单独调用内部过程时,它返回正确的值。是什么赋予了?这可能很简单,但我没有看到它。

外部过程

DELIMITER $$

USE `automation`$$

DROP PROCEDURE IF EXISTS `pd_build_script`$$

CREATE DEFINER=`user`@`%` PROCEDURE `pd_build_script`(
IN autom_type INT(3),
IN auto_font VARCHAR(30),
IN auto_design VARCHAR(10),
IN auto_d_only TINYINT(1),
IN auto_job VARCHAR(255),
IN auto_template VARCHAR(75)
)
BEGIN
DECLARE font VARCHAR(30);
DECLARE design_script TEXT;

SELECT indesign_name INTO font FROM automation.`indesign_font` WHERE auto_type = autom_type AND web_name = auto_font;
IF (auto_design = "PD00") THEN
CALL pd00(font, @out_script);
ELSEIF (auto_design = "PD1" OR auto_design = "PD73" OR auto_design = "PD88"
OR auto_design = "PD97") THEN
CALL single_letter_art(font, auto_design, auto_d_only, @out_script);
ELSEIF (auto_design = "PD2") THEN
CALL pd2(font, auto_d_only, @out_script);
ELSEIF (auto_design = "PD3") THEN
CALL pd3(font, auto_d_only, @out_script);
ELSEIF (auto_design = "PD28") THEN
CALL pd28(font, auto_d_only, @out_script);
ELSE
CALL pd_general(font, auto_design, auto_d_only, @out_script);
END IF;

SET design_script = CONCAT("some text", @out_script, "more text");
INSERT INTO automation.`job_script` (job_id, script, batch)
VALUE (auto_job, @out_script, CONCAT('batch text', auto_job));
END$$

DELIMITER ;

内部程序

DELIMITER $$

USE `automation`$$

DROP PROCEDURE IF EXISTS `pd2`$$

CREATE DEFINER=`user`@`%` PROCEDURE `pd2`(
IN font VARCHAR(30), design_only TINYINT(1), OUT layers TEXT
)
BEGIN
DECLARE layer TEXT;
DECLARE links TEXT;
IF (design_only = 1) THEN
SET layer = "layer text";
ELSE
SET layer = CONCAT("layer text",font,"more layer text");
END IF;
#Set the links for the design.
SET links = "links";
SELECT CONCAT(layer,links) INTO layers;
END$$

DELIMITER ;

最佳答案

找出问题所在。字体变量的选择返回 null,因为传递的选项不在数据库中。这导致了空数据的级联。问题实际上并不在代码中。

关于mysql - 为什么 mySQL 过程在从过程内部调用时返回 null,但在单独调用时则不返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45471446/

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