<bdo id='waDs0'></bdo><ul id='waDs0'></ul>

      <legend id='waDs0'><style id='waDs0'><dir id='waDs0'><q id='waDs0'></q></dir></style></legend>
    1. <i id='waDs0'><tr id='waDs0'><dt id='waDs0'><q id='waDs0'><span id='waDs0'><b id='waDs0'><form id='waDs0'><ins id='waDs0'></ins><ul id='waDs0'></ul><sub id='waDs0'></sub></form><legend id='waDs0'></legend><bdo id='waDs0'><pre id='waDs0'><center id='waDs0'></center></pre></bdo></b><th id='waDs0'></th></span></q></dt></tr></i><div id='waDs0'><tfoot id='waDs0'></tfoot><dl id='waDs0'><fieldset id='waDs0'></fieldset></dl></div>

    2. <small id='waDs0'></small><noframes id='waDs0'>

        <tfoot id='waDs0'></tfoot>

        存储过程中的 MySQL PREPARE 语句

        时间:2023-10-26

        <tfoot id='7Dc5M'></tfoot>
          <legend id='7Dc5M'><style id='7Dc5M'><dir id='7Dc5M'><q id='7Dc5M'></q></dir></style></legend>

          <small id='7Dc5M'></small><noframes id='7Dc5M'>

                <tbody id='7Dc5M'></tbody>
                <bdo id='7Dc5M'></bdo><ul id='7Dc5M'></ul>
                  <i id='7Dc5M'><tr id='7Dc5M'><dt id='7Dc5M'><q id='7Dc5M'><span id='7Dc5M'><b id='7Dc5M'><form id='7Dc5M'><ins id='7Dc5M'></ins><ul id='7Dc5M'></ul><sub id='7Dc5M'></sub></form><legend id='7Dc5M'></legend><bdo id='7Dc5M'><pre id='7Dc5M'><center id='7Dc5M'></center></pre></bdo></b><th id='7Dc5M'></th></span></q></dt></tr></i><div id='7Dc5M'><tfoot id='7Dc5M'></tfoot><dl id='7Dc5M'><fieldset id='7Dc5M'></fieldset></dl></div>
                  本文介绍了存储过程中的 MySQL PREPARE 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个 sql 文件:

                  I have this sql file:

                  USE mydb;
                  
                  DROP PROCEDURE IF EXISTS execSql;
                  DELIMITER //
                  CREATE PROCEDURE execSql (
                                       IN sqlq VARCHAR(5000)
                                        ) COMMENT 'Executes the statement'
                  BEGIN
                    PREPARE stmt FROM sqlq;
                    EXECUTE stmt;
                    DEALLOCATE PREPARE stmt;
                  END //
                  DELIMITER ;          
                  

                  当我尝试运行它时

                  # cat file.sql |mysql -p

                  # cat file.sql | mysql -p

                  我明白

                  ERROR 1064 (42000) at line 6: You have an error in your SQL syntax; check the manual
                  that corresponds to your MySQL server version for the right syntax to use near 'sqlq;
                    EXECUTE stmt;
                    DEALLOCATE PREPARE stmt;
                    END' at line 5
                  

                  我做错了什么?

                  推荐答案

                  您只能准备和执行 字符串文字用户定义的变量,包含语句的文本.

                  You can only prepare and execute SQL that's a string literal or a user-defined variable that contains the text of the statement.

                  试试这个:

                  USE mydb;
                  
                  DROP PROCEDURE IF EXISTS execSql;
                  DELIMITER //
                  
                  CREATE PROCEDURE execSql (IN sqlq VARCHAR(5000)) COMMENT 'Executes the statement'
                  BEGIN
                    SET @sqlv = sqlq;
                    PREPARE stmt FROM @sqlv;
                    EXECUTE stmt;
                    DEALLOCATE PREPARE stmt;
                  END //
                  
                  DELIMITER ;      
                  

                  这篇关于存储过程中的 MySQL PREPARE 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:存储过程和实体框架 4.0 中的表值参数 下一篇:从 SSIS 上的脚本任务执行时,Oracle 过程不返回结果

                  相关文章

                  <tfoot id='TjvUQ'></tfoot>
                1. <i id='TjvUQ'><tr id='TjvUQ'><dt id='TjvUQ'><q id='TjvUQ'><span id='TjvUQ'><b id='TjvUQ'><form id='TjvUQ'><ins id='TjvUQ'></ins><ul id='TjvUQ'></ul><sub id='TjvUQ'></sub></form><legend id='TjvUQ'></legend><bdo id='TjvUQ'><pre id='TjvUQ'><center id='TjvUQ'></center></pre></bdo></b><th id='TjvUQ'></th></span></q></dt></tr></i><div id='TjvUQ'><tfoot id='TjvUQ'></tfoot><dl id='TjvUQ'><fieldset id='TjvUQ'></fieldset></dl></div>

                  <small id='TjvUQ'></small><noframes id='TjvUQ'>

                  • <bdo id='TjvUQ'></bdo><ul id='TjvUQ'></ul>

                2. <legend id='TjvUQ'><style id='TjvUQ'><dir id='TjvUQ'><q id='TjvUQ'></q></dir></style></legend>