Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE FUNCTION Calculator ( @Opd1 bigint, @Opd2 bigint, @Oprt char(1) = '*' ) RETURNS bigint AS BEGIN DECLARE @Result bigint SET @Result = CASE @Oprt WHEN '+' THEN @Opd1 + @Opd2 WHEN '-' THEN @Opd1 - @Opd2 WHEN '*' THEN @Opd1 * @Opd2 WHEN '/' THEN CASE WHEN @Opd2 = 0 THEN NULL ELSE @Opd1 / @Opd2 END ELSE NULL END RETURN @Result END;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear