I'm used to working in MS SQL Server, so MySQL is always a little bit foreign to me. I wrote the following for MS SQL Server, and I'm trying to port it to MySQL:
CREATE FUNCTION ToRadians
(@Degrees float)
RETURNS float
AS
BEGIN
DECLARE @Radians float
SELECT @Radians = @Degrees * 3.1415927 / 180
RETURN @Radians
END
GO
I've got
CREATE FUNCTION ToRadians
(@Degrees float)
RETURNS float
BEGIN
DECLARE @Radians float;
SELECT @Radians = @Degrees * 3.1415927 / 180;
RETURN @Radians;
END
but in PHPMyAdmin, that gives me the error:
Error
SQL query:
CREATE FUNCTION ToRadians(
@Degrees float
) RETURNS float AS BEGIN DECLARE@Radians float;
MySQL said: Documentation
#1064 - 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 '@Degrees float)
RETURNS float
AS
BEGIN
DECLARE @Radians float' at line 2
The searching I've done indicates that the above MySQL UDF should be correct, but it obviously isn't. SELECT version() returns 5.0.77