Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 参考 » 使用 SQL » SQL 函数 » SQL 函数 (P-Z)

 

VAREXISTS 函数 [Miscellaneous]

如果已使用给定名创建或声明了用户定义变量,则返回 1。如果未创建这样的变量,则返回 0。

语法
VAREXISTS( variable-name-string )
参数
  • variable-name-string   要测试的变量名(字符串形式)。

返回值

INT

另请参见
标准和兼容性
  • SQL/2003   服务商扩充。

示例

以下 IF 语句创建一个名为 start_time 的变量(如果尚未创建或声明该变量)。之后便可安全地使用该变量。

IF VAREXISTS( 'start_time' ) = 0 THEN
    CREATE VARIABLE start_time TIMESTAMP;
END IF;
SET start_time = current timestamp;