add row存储过程不工作

zf9nrax1  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(250)

我正在尝试运行一个存储过程来向数据库中添加电影。我已经让“getallfilms”的存储过程工作了,但是当我运行addfilm时,它出现了一个错误:“找不到”
在mysql中,存储过程的工作原理是:

CREATE DEFINER=`sherattd`@`%` PROCEDURE `addFilm`(in Title varchar(45), in 
    Year int, in Director varchar(45), in Stars varchar(45), in Review 
    varchar(45))
BEGIN
    insert into films (title, year, director, stars, review) values (Title, 
    Year, Director, Stars, Review);
END

当我在visual studio上调用它时,它会出错:

var express = require('express');
var router = express.Router();
var config = require('config');
var http = require("http");
var mysql = require('mysql');
var request 
//Add Film
router.post('/api/addFilm/:title/:year/:director/:stars/:review', function (req, res) {
console.log("hello");

var Title = req.params['title'];
var Year = req.params['year'];
var Director = req.params['director'];
var Stars = req.params['stars'];
var Review = req.params['review'];

var con = mysql.createConnection({
    host: config.get('EPAssignment.database.host'),
    user: config.get('EPAssignment.database.user'),
    password: config.get('EPAssignment.database.password'),
    database: config.get('EPAssignment.database.database')
});
console.log("hello x2");

con.connect(function (err) {
    if (err) throw err;
    con.query("CALL addFilm('" + Title + "', '" + Year + "', '" + Director + "', '" + Stars + "', '" + Review + "');", function (err, result, fields) {

        if (err) throw err;
        console.log(result);
        console.log("hello x3");
        res.send(result[0]);
    });
});

});= require('request');

当我调用它时,使用(test,2000,test,test,test)的测试值,控制台记录:

App GET [404] /api/addFilm/Test/2000/Test/Test/Test

谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题