SelectDB Cloud
SQL 手册
SQL 函数
条件函数
ASSERT_TRUE

Description

Syntax

BOOLEAN assert_true(BOOLEAN condition, VarcharLiteral errmsg)

conditiontrue 时, 返回 true. 否则抛出一个异常,异常信息为 errmsg. errmsg 必须为字面量。

Example

mysql> select assert_true(1, "wrong");
+------------------------------------------+
| assert_true(cast(1 as BOOLEAN), 'wrong') |
+------------------------------------------+
|                                        1 |
+------------------------------------------+
1 row in set (0.12 sec)
 
mysql> select assert_true(1, nullable("wrong"));
ERROR 1105 (HY000): errCode = 2, detailMessage = assert_true only accept constant for 2nd argument
mysql> select assert_true(0, "wrong");
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong
mysql> select assert_true(null, "wrong");
ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.8)[INVALID_ARGUMENT][E33] wrong

Keywords

ASSERT_TRUE, ASSERT, TRUE
© 2023 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标