SQL for Reality > SQL Stored Procedures > BEGIN/END Statements

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.

RealityV15.1Online Documentation (MoTW) Revision 7

BEGIN/END Statements (SQL) (m691509+beginend.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

BEGIN/END Statements

Groups a series of SQL statements so that they can be treated as a single statement.

Syntax

BEGIN
    statement
    {statement
    {...}}
END

Syntax Elements

statement
Any supported SQL statement.

Comments

BEGIN and END statements are used to group the statements that form a procedure, and to allow the IF and WHILE statements to control multiple SQL statements.

Examples

CREATE PROC EX1 AS
BEGIN
-- currency conversion table
CREATE TABLE CONV (CID VARCHAR(5) PRIMARY KEY, RATE DECIMAL(5,2), CNAME VARCHAR(5))
-- test data table
CREATE TABLE TESTDATA (ID SMALLINT PRIMARY KEY, AMT DECIMAL(6,2))
END

Creates a procedure called EX1 that creates two tables. The two CREATE statements are grouped using a BEGIN/END block.

SET @I = 0
SET @V1 = SECOND(CURTIME())+1
WHILE @I<10
BEGIN
SET @I = @I+1
SET @V2 = @V1*@I + @V1/@I
INSERT INTO TESTDATA VALUES(@I,@V2)
END

Groups three statements together for execution in a loop.

See Also

CREATE PROCEDURE statement, IF statement, WHILE statement.

RealityV15.1 (MoTW) Revision 7Comment on this topic