Example

Use a RETURN statement to return from an SQL procedure with a status value of zero if successful, and -200 if not.

 BEGIN
   ...
   GOTO fail;
   ...
   success: RETURN 0
   failure: RETURN -200
...
END                                      

Define a scalar function that returns the tangent of a value using the existing sine and cosine functions.

 CREATE FUNCTION mytan (x DOUBLE)
   RETURNS DOUBLE
   LANGUAGE SQL
   CONTAINS SQL
   NO EXTERNAL ACTION
   DETERMINISTIC
   RETURN SIN(x)/COS(x)