MySQL Forums
Forum List  »  Stored Procedures

Display all 761 possibilities trying to create function
Posted by: RockV
Date: August 23, 2005 01:08AM

Hello,

I am having this problem.
If someone knows what is happening please let me know.

I am trying to create this function:

DROP FUNCTION fn_add_prefix;
delimiter //
CREATE FUNCTION fn_add_prefix(in_numero VARCHAR(50)) RETURNS VARCHAR(50)
BEGIN
DECLARE xResultado VARCHAR(50);
DECLARE xContinuar INT DEFAULT 1;
WHILE xContinuar = 1 DO
SELECT CONCAT(Rewrite, RIGHT('093901238',CHAR_LENGTH('093901238') - CHAR_LENGTH(Prefix))), Recheck INTO xResultado, xContinuar FROM Prefixes WHERE Prefix = LEFT('093901238',CHAR_LENGTH(Prefix)) ORDER BY CHAR_LENGTH(Prefix) DESC LIMIT 1;
END WHILE;
RETURN xResultado;
END
//
delimiter ;

But I get the following:

mysql> DROP FUNCTION fn_add_prefix;
ERROR 1305 (42000): FUNCTION e-psylon.fn_add_prefix does not exist
mysql> delimiter //
mysql> CREATE FUNCTION fn_add_prefix(in_numero VARCHAR(50)) RETURNS VARCHAR(50)
-> BEGIN
-> DECLARE xResultado VARCHAR(50);
-> DECLARE xContinuar INT DEFAULT 1;
-> WHILE xContinuar = 1 DO
->
Display all 761 possibilities? (y or n)
AccountID Countries.TLD ProviderIPs.HostModified
...
...
...
Here, I get all my database tables...
...
...
...
-> CAT(Rewrite, RIGHT('093901238',CHAR_LENGTH('093901238') - CHAR_LENGTH(Prefix))), Recheck INTO xResultado, xContinuar FROM Prefixes WHERE Prefix = LEFT('093901238',CHAR_LENGTH(Prefix)) ORDER BY CHAR_LENGTH(Prefix) DESC LIMIT 1;
-> END WHILE;
-> RETURN xResultado;
-> 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 '(Rewrite, RIGHT('093901238',CHAR_LENGTH('093901238') - CHAR_LENGTH(Prefix))), Re' at line 6
mysql> delimiter ;
mysql> Aborted

For some reason, the server try to show me other possibilities each time I try to use WHILE or IF.

RockV

Options: ReplyQuote


Subject
Views
Written By
Posted
Display all 761 possibilities trying to create function
6067
August 23, 2005 01:08AM


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.