不能创建别名`if` if`或``ifnull''

发布于 2025-01-27 17:31:44 字数 756 浏览 1 评论 0原文

如果,我正在尝试在H2Database中创建一个别名,并且我会收到以下错误。

org.h2.jdbc.JdbcSQLSyntaxErrorException: Function alias "IF" already exists; SQL statement:

CREATE ALIAS `IF` FOR "test.Udf.ifAlias" [90076-212]

然后,我尝试在创建之前将if删除,然后收到以下错误。

org.h2.jdbc.JdbcSQLSyntaxErrorException: Function alias "IF" not found; SQL statement:

DROP ALIAS `IF` [90077-212]

IFNULL发生了类似的情况。我正在初始脚本中尝试以下几行。

DROP ALIAS `IF`;
CREATE ALIAS `IF` FOR "test.Udf.ifAlias";

ifalias的Java功能是

  public static boolean ifAlias(boolean condition, boolean exp1, boolean exp2) {
    if(condition) {
      return exp1;
    }
    return exp2;
  }

I am trying to create an alias in H2database for IF and I get the following error.

org.h2.jdbc.JdbcSQLSyntaxErrorException: Function alias "IF" already exists; SQL statement:

CREATE ALIAS `IF` FOR "test.Udf.ifAlias" [90076-212]

Then I try to drop the IF before creating, and I get the following error.

org.h2.jdbc.JdbcSQLSyntaxErrorException: Function alias "IF" not found; SQL statement:

DROP ALIAS `IF` [90077-212]

Similar happens for IFNULL. I am trying the following lines in my init script.

DROP ALIAS `IF`;
CREATE ALIAS `IF` FOR "test.Udf.ifAlias";

And the Java function for the ifAlias is

  public static boolean ifAlias(boolean condition, boolean exp1, boolean exp2) {
    if(condition) {
      return exp1;
    }
    return exp2;
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Since version 1.4.198, IF is a keyword in h2. See this issue and responses: https://github.com/h2database/h2database/issues/3018

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文