Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
Watcom SQL IF 文の代わりに、SQL 文の条件付き実行を制御します。
IF expression statement [ ELSE [ IF expression ] statement ]
Transact-SQL IF と ELSE は、それぞれ単一の SQL 文または複合文 (キーワード BEGIN と END の間) の実行を制御します。
Watcom SQL IF 文と比較すると、Transact-SQL IF 文には THEN がありません。Transact-SQL バージョンには、ELSEIF または END IF キーワードもありません。
なし
SQL/2008 Transact-SQL 拡張。
次の例は、Transact-SQL IF 文の使い方を示します。
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
次の 2 つの文のブロックは、Transact-SQL と Watcom SQL の互換性を示します。
/* Transact-SQL IF statement */ IF @v1 = 0 PRINT '0' ELSE IF @v1 = 1 PRINT '1' ELSE PRINT 'other' /* Watcom SQL IF statement */ IF v1 = 0 THEN PRINT '0' ELSEIF v1 = 1 THEN PRINT '1' ELSE PRINT 'other' END IF