帆软数据集使用if函数

有两段sql,sql1和sql2相互独立,且都用到了if函数判断参数为空则默认全部。最外层想通过flag参数判断数据集执行哪一段sql。

sql1: 

select * from tableA

where timekey>=to_char(sysdate,'yyyymmddhh24miss')||'0730'

${if(len(t_type)==0,"","and t_typein('"+t_type+"')")}

sql2:

select * from tableB

where timekey>=to_char(sysdate,'yyyymmddhh24miss')||'0730'

${if(len(t_type)==0,"","and t_type in('"+t_type+"')")}

怎么把这两段sql再嵌套进if条件里面

${if(flag='Cur',"","")} 

FineReport FR小菜鸡 发布于 2021-11-19 16:24
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
让过去Lv6中级互助
发布于2021-11-19 16:31(编辑于 2021-11-19 16:32)

image.png试一下。。。

${IF(FLAG='Cur',

"select 

from tableA

where timekey>=to_char(sysdate,'yyyymmddhh24miss')||'0730'"

+if(len(t_type)==0,""," and t_type in('"+t_type+"')")

,

"select 

from tableB

where timekey>=to_char(sysdate,'yyyymmddhh24miss')||'0730'"

+if(len(t_type)==0,""," and t_type in('"+t_type+"')")

)}

最佳回答
1
linbodingLv6中级互助
发布于2021-11-19 16:30

select * from ${if(flag='Cur',"tablea","tableb")}

where timekey>=to_char(sysdate,'yyyymmddhh24miss')||'0730'

${if(len(t_type)==0,"","and t_typein('"+t_type+"')")}

  • 3关注人数
  • 327浏览人数
  • 最后回答于:2021-11-19 16:32
    请选择关闭问题的原因
    确定 取消
    返回顶部