Mysql stored procedure question _ MySQL

Source: Internet
Author: User
Mysql stored procedure problems bitsCN.com started to run with phpMyAdmin, and then a bunch of errors occurred. after that, the begin is removed and can be executed normally after the end, but to execute the stored procedure, it won't work in phpMyAdmn, in the mysql command line text box, you can.
Next, I encountered a more difficult problem. I added a preprocessing statement to the stored procedure, but it was even worse. I executed the same statement in the mysql command line text box. the following running records are for your reference, can someone help me.

Mysql> create procedure catalog_get_products_in_category (
-> IN inCategoryId INT, IN inmo-productdescriptionlength INT,
-> IN inProductsPerPage INT, IN inStartItem INT)
-> Begin
-> SELECT p. product_id, p. name, IF (LENGTH (p. description) <= in1_productd
EscriptionLength, p. description,
-> CONCAT (LEFT (p. description, inmo-productdescriptionlength), '...')
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

// Original stored procedure statement
Eate procedure catalog_get_products_in_category (
IN inCategoryId INT, IN inner productdescriptionlength 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 = inmo-productdescriptionlength;
SET @ p2 = inmo-productdescriptionlength;
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 inmo-productdescriptionlength 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 = inmo-productdescriptionlength;
-> SET @ p2 = inmo-productdescriptionlength;
-> 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

There are two stored procedures, one with no preprocessing statement and the other with preprocessing statement,
Afterwards, I sent an email to the author, without a reply, and sent an email to the mysql official website. Currently, you can only seek help from senior personnel. BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.