H2中的IF函数实现MySQL兼容性 [英] IF function in H2 for MySQL compatibility

查看:1055
本文介绍了H2中的IF函数实现MySQL兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用H2(具有MySQL兼容模式)针对我们使用MySQL的软件编写一些自动化测试.不幸的是,似乎H2没有许多查询使用的IF函数.除了使用DECODE之类的代码重写应用查询之外,它们是创建if函数(如Alias)的好方法吗?

I'm using H2 (with MySQL compatibility mode) to write some automated tests against our software that uses MySQL. Unfortunately, it seems like H2 does not have have the IF function that many of our queries use. Short of rewriting our application queries with something like DECODE, is their a good way to create the if function, say as an Alias?

我得到的错误:

WARNING: Failed to execute: SELECT IF(true,'TRUE!!','FALSE!!!') because: Function "IF" not found; SQL statement:

推荐答案

最终只是重写查询以使用与两个数据库都兼容的功能-H2,MySql.就我而言,有问题的功能被IFNULL取代了.

Ended up just rewriting queries to use functions compatible with both database - H2, MySql. In my case, the functions in question were replaced with IFNULL.

这篇关于H2中的IF函数实现MySQL兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆