SQL for Reality > SQL Stored Procedures > RETURN Statement

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

Reality V15.0 ()

RETURN Statement (SQL) (m691509+return.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

RETURN Statement

Causes an immediate exit from a called procedure.

Syntax

RETURN {expression}

Syntax Elements

expression
Any valid SQL expression that evaluates to a single (scalar) value with a data type that is compatible with the declared return value of the procedure.

Comments

Any statements following the RETURN statement are skipped.

Example

CREATE PROC EX7(@TYPE INTEGER IN) RETURNS DECIMAL(6,2) AS
BEGIN
DECLARE @V DECIMAL(6,2)
IF @TYPE=1
SET @V = (SELECT MIN(AMT) FROM TESTDATA)
ELSE IF @TYPE=2
SET @V = (SELECT MAX(AMT) FROM TESTDATA)
ELSE
SET @V = (SELECT AVG(AMT) FROM TESTDATA)
RETURN @V
END

Creates a procedure called EX7 that returns the minimum, maximum or average value from the AMT column of the TESTDATA table, depending on the value of the @TYPE parameter.

See Also

CREATE PROCEDURE statement.

RealityV15.0Comment on this topic