MySQL Forums
Forum List  »  Stored Procedures

Stored procedure
Posted by: Piotr Gacek
Date: December 19, 2014 08:37AM

Hello,

I have a problem with a stored procedure (mysql server ver 5.0.18)
Quote

CREATE PROCEDURE `some_funnc`(IN startIndex INT, IN countNum INT, OUT var1 INT)
READS SQL DATA
BEGIN
declare vaar1 int;
SET @assd = CONCAT('SELECT `id_book` into ',var1,' FROM `suitcase_booking` LIMIT ',startIndex,',',countNum);
PREPARE zxc FROM @assd;
EXECUTE zxc;
END

When I run it, it returns error
Quote

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 'NULL' at line 1

Why this is not working?

Generally I am using PLC with MES interface, and I want to read n-th row element from database and store it in PLC register. Everything works fine, except this OUT parameter. When I delete the "... into ',var1,' ..." it doesn't return error, but it also doesnt return any data.
I have tried different versions and IN parameters for limit works fine, but when I assign INTO section of SELECT it fails.

If it is not possible in that way, how can I do it another way? (Stored procedure only, as the PLC module doesnt support functions).

Please help me with this matter

Options: ReplyQuote


Subject
Views
Written By
Posted
Stored procedure
2937
December 19, 2014 08:37AM
1141
December 19, 2014 02:49PM
1098
December 22, 2014 03:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.