本文介绍了解码等效于Postgres的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
没有等效于Oracle
的DECODE()'Function In
Postgres`.有没有人写过解码为函数?
There is no equivalent to the Oracle
's DECODE()'Function In
Postgres`. Is there anyone who wrote decode as a Function?
推荐答案
有一个等效项.它称为 CASE
语句.
There is an equivalent. It's called a CASE
statement.
CASE有两种形式:
There are two forms of CASE:
简单案例:
CASE search-expression
WHEN expression [, expression [ ... ]] THEN
statements
[ WHEN expression [, expression [ ... ]] THEN
statements
... ]
[ ELSE
statements ]
END CASE;
搜索到的案例:
CASE
WHEN boolean-expression THEN
statements
[ WHEN boolean-expression THEN
statements
... ]
[ ELSE
statements ]
END CASE;
CASE
语句更易于阅读;我更喜欢这些,而不是Oracle中的decode()
.
CASE
statements are easier to read; I prefer these over decode()
in Oracle.
这篇关于解码等效于Postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!