怎么根据不同的条件执行不同的sql?orcale
select * from Aselect * from B where year='2021'select * from c where week='202105'
select * from A
select * from B where year='2021'
select * from c where week='202105'
当B,C表没有传递条件,查询A;当B有条件查询B表;当C有条件查询C表;B,C都有条件,只查C
有啥函数可用?
逻辑有问题啊
按照你的描述 是否当B,C都有值则只查询B不管C???
AB都有查询哪个表?
一看你这逻辑就有漏洞啊
${
IF(LEN(YEAR)>0,"select * from B WHERE YEAR='"+YEAR+"'",
IF(LEN(week)>0,"select * from C WHERE WEEK='"+week+"'",
"select * from A"
)
}
写个简单的存储过程,把你的条件作为数据集的参数,把参数传到存储过程并获取参数字符长度作为if判断条件。长度为0查A表,等于6查C表,其他查B表