admin管理员组文章数量:1794759
postgresql兼容MySQL if函数
if函数说明:
在MySQL中if()函数的用法类似于java中的三目表达式,其用处也比较多,具体语法如下: IF(expr1,expr2,expr3),如果expr1的值为true,则返回expr2的值,如果expr1的值为false,则返回expr3的值
postgresql自定义if函数兼容: ```sql create or replace function if(bln boolean,inValue1 anyelement,inValue2 anyelement) returns anyelement as $$ begin if bln=true then return inValue1; else return inValue2; end if; end; $$ language plpgsql; create or replace function if(bln boolean,inValue1 numeric,inValue2 numeric) returns numeric as $$ begin if bln=true then return inValue1; else return inValue2; end if; end; $$ language plpgsql; create or replace function if(bln boolean,inValue1 numeric,inValue2 text) returns text as $$ begin if bln=true then return inValue1; else return inValue2; end if; end; $$ language plpgsql;本文标签: 函数postgresqlmySQL
版权声明:本文标题:postgresql兼容MySQL if函数 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686499996a74413.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论