I've looked through several other possible solutions here on stack overflow but I'm still stuck. The following code is just a simplified version of what I'm trying to do.
Running
select CONVERT( '1510SBrownlee' , SIGNED INTEGER);
works perfeclty fine. It returns 1510 as expected.
The issue arises when the same code is placed in a function. (Again, please note that this is not my actual function, I'm using the following as a simple example... In my actual function, I'm passing a parameter).
After creating
DELIMITER //
CREATE FUNCTION testing_function() RETURNS varchar(255)
BEGIN
DECLARE testt varchar(255);
SET testt = CONVERT( '1510SBrownlee' , SIGNED INTEGER);
RETURN testt;
END //
DELIMITER ;
I get the following error when I run select testing_function();
ERROR 1292 (22007): Truncated incorrect INTEGER value: '1510SBrownlee'
Why is this working when I run it directly as opposed to when in a function? Is there a way to make that work in the function? I've also tried CAST as SIGNED as opposed to CONVERT. Same issue.
Thanks in advance.