MySQL:“字段列表"中的未知列 [英] MySQL: Unknown column in 'field list'

查看:73
本文介绍了MySQL:“字段列表"中的未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉 MySQL 中的存储过程.为什么我的存储过程开头...

I'm new to stored procedures in MySQL. Why is the beginning of my stored procedure...

DROP PROCEDURE IF EXISTS videodb.addVideo;
CREATE PROCEDURE videodb.addVideo(vidTitle VARCHAR(255), vidDescription VARCHAR(500), producerArray VARCHAR(500), actorArray VARCHAR(500), OUT vidSuccess BOOL)
    START TRANSACTION;
            SET @videoInsertVar = 'INSERT INTO videodb.videos (id, title, description) VALUES(?, ?, ?)';
            SET @videoId = NULL;
            SET @videoTitle = vidTitle; -- this is line 69

...产生这个奇怪的错误...

...producing this strange error...

ERROR 1054 (42S22) at line 69: Unknown column 'vidTitle' in 'field list'

推荐答案

您的问题是,引发错误的语句实际上 在您的程序之外,因此, - 在其参数范围之外.解决方案是将整个过程的routine_body 包装成一个BEGIN ... END 结构以创建一个复合语句.

Your problem is that the statement that throws the error is actually outside of your procedure and, thus, - outside of its parameters scope. The solution is to wrap the entire routine_body of the procedure into a BEGIN ... END structure to create a Compound Statement.

创建程序 在其主体中需要有效的 SQL 例程语句".使用复合语句语法允许将多个语句组合成单个代码块并符合此要求.

CREATE PROCEDURE expects a "Valid SQL routine statement" in its body. Using the Compound-Statement Syntax allows to group multiple statements into a single code-block and comply with this requirement.

这篇关于MySQL:“字段列表"中的未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆