EasyManua.ls Logo

Sybase Adaptive Server Anywhere - IF Statement [T-SQL]

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 9 SQL Statements
547
IF statement [T-SQL]
Use this statement to control conditional execution of a SQL statement, as an
alternative to the Watcom-SQL IF statement.
IF
expression
statement
… [ ELSE
… [ IF
expression
]
statement
]
None.
None.
The Transact-SQL IF conditional and the ELSE conditional each control the
execution of only a single SQL statement or compound statement (between
the keywords BEGIN and END).
In comparison to the Watcom-SQL IF statement, there is no THEN in the
Transact-SQL IF statement. The Transact-SQL version also has no ELSEIF
or END IF keywords.
SQL/92 Transact-SQL extension.
Sybase Adaptive Server Enterprise supports the Transact-SQL IF
statement.
The following example illustrates the use of the Transact-SQL IF
statement:
IF (SELECT max(id) FROM sysobjects) < 100
RETURN
ELSE
BEGIN
PRINT "These are the user-created objects"
SELECT name, type, id
FROM sysobjects
WHERE id < 100
END
The following two statement blocks illustrate Transact-SQL and
Watcom-SQL compatibility:
/* Transact-SQL IF statement */
IF @v1 = 0
PRINT ’0’
ELSE IF @v1 = 1
PRINT ’1’
ELSE
PRINT ’other’
/* Watcom-SQL IF statement */
Function
Syntax
Authorization
Side effects
Description
Standards and
compatibility
Example

Table of Contents

Related product manuals