select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as checkin_time, '${personType}'as bd_type, 'AA.AA.AA.AA'as checkin_window_ip from compare_result where from_station in ('QTP','CTH','CLP','BDP','BEP','SHD') or to_station in ('QTP','CTH','CLP','BDP','BEP','SHD')
select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as checkin_time, '${personType}'as bd_type, 'AA.AA.AA.AA'as checkin_window_ip from compare_result where board_station in (${fromStationCode}) or to_station in (${toStationCode})
执行后发现有语法错误,意识到变量引用应该放到单引号里面,于是,改成了下面这样:
select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as checkin_time, '${personType}'as bd_type, 'AA.AA.AA.AA'as checkin_window_ip from compare_result where board_station in ('${fromStationCode}') or to_station in ('${toStationCode}')
这样解析出来的SQL是有问题的,in里面的值最外面多了一层单引号:
select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as checkin_time, '${personType}'as bd_type, 'AA.AA.AA.AA'as checkin_window_ip from compare_result where from_station in (''QTP','CTH','CLP','BDP','BEP','SHD'') or to_station in (''QTP','CTH','CLP','BDP','BEP','SHD'')
select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as checkin_time, '${personType}' as bd_type, 'AA.AA.AA.AA' as checkin_window_ip from compare_result where board_station in (%%fromStationCode%%) or to_station in (%%toStationCode%%)