mysql 存儲進程的成績。本站提示廣大學習愛好者:(mysql 存儲進程的成績)文章只能為提供參考,不一定能成為您想要的結果。以下是mysql 存儲進程的成績正文
一開端用phpMyAdmin來履行,後來湧現一堆毛病,後往來來往失落了begin,end以後可以正常履行,但要履行存儲進程,在phpMyAdmn中不可,而在mysql敕令行文本框中便可以。
接上去又碰到更難的成績,在存儲進程中參加預處置語句,更不可了,在mysql敕令行文本框下履行異樣,上面的運轉記載,給年夜家參考,可否有高手來贊助。
mysql> CREATE PROCEDURE catalog_get_products_in_category(
-> IN inCategoryId INT, IN inShortProductDescriptionLength INT,
-> IN inProductsPerPage INT, IN inStartItem INT)
-> begin
-> SELECT p.product_id, p.name,IF(LENGTH(p.description) <= inShortProductD
escriptionLength, p.description,
-> CONCAT(LEFT(p.description, inShortProductDescriptionLength),'...')) AS
description, p.price, p.discounted_price, p.thumbnail
-> FROM product p INNER JOIN product_category pc ON p.product_id = pc.pro
duct_id
-> WHERE pc.category_id = inCategoryId
-> ORDER BY p.display DESC
-> LIMIT inStartItem;inProductsPerPage;
-> end$$
ERROR 1064 (42000): 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 'inSta
rtItem;inProductsPerPage;
end' at line 10
//本來的存儲進程語句
EATE PROCEDURE catalog_get_products_in_category(
IN inCategoryId INT, IN inShortProductDescriptionLength INT,
IN inProductsPerPage INT, IN inStartItem INT)
BEGIN
PREPARE statement FROM
"SELECT p.product_id, p.name,IF(LENGTH(p.description) <= ?, p.description,
CONCAT(LEFT(p.description, ?),'...')) AS description, p.price, p.discounted_price, p.thumbnail
FROM product p INNER JOIN product_category pc ON p.product_id = pc.product_id
WHERE pc.category_id = ?
ORDER BY p.display DESC
LIMIT ?, ?";
SET @p1 = inShortProductDescriptionLength;
SET @p2 = inShortProductDescriptionLength;
SET @p3 = inCategoryId;
SET @p4 = inStartItem;
SET @p5 = inProductsPerPage;
EXECUTE statement USING @p1, @p2, @p3, @p4, @p5;
END$$
mysql> delimiter $$
mysql> CREATE PROCEDURE catalog_get_products_in_category(
-> IN inCategoryId INT, IN inShortProductDescriptionLength INT,
-> IN inProductsPerPage INT, IN inStartItem INT)
-> BEGIN
-> PREPARE statement FROM
-> "SELECT p.product_id, p.name,IF(LENGTH(p.description) <= ?, p.descript
ion,
"> CONCAT(LEFT(p.description, ?),'...')) AS description, p.price, p.disco
unted_price, p.thumbnail
"> FROM product p INNER JOIN product_category pc ON p.product_id = pc.pro
duct_id
"> WHERE pc.category_id = ?
"> ORDER BY p.display DESC
"> LIMIT ?, ?";
-> SET @p1 = inShortProductDescriptionLength;
-> SET @p2 = inShortProductDescriptionLength;
-> SET @p3 = inCategoryId;
-> SET @p4 = inStartItem;
-> SET @p5 = inProductsPerPage;
-> EXECUTE statement USING @p1, @p2, @p3, @p4, @p5;
-> END$$
ERROR 1314 (0A000): PREPARE is not allowed in stored procedures
下面有兩個存儲進程,一個不消預處置語句,一個用了預處置語句,
以後,向作者發過郵件,沒有回答,又給mysql官方發過郵件,異樣沒回答。當今只能乞助諸位高人。