TBL_NAMECOLM_NAMEOPER_CODERULE_CMPAR_VALUEAND_OR_OR
STORE_DISTRORTE_ID=22410034A
STORE_MASTERZONE=贵州
需要拼接成:
STORE_DISTRO.RTE_ID='22410034' and STORE_MASTER.ZONE='贵州'
1. 创建临时表存放查询后的数据,临时表可以根据实际查询结果创建(create table wmedi.wave_distro_filter... ..)
2. 创建自定义函数get_wave_query_param,用来拼接完整的Where条件
3. 定义sql字符,后面接上get_wave_query_param函数返回的筛选条件,通常情况下PL/SQL是不能直接运行的,需要用到execute immediate执行SQL,写入临时表,最后从临时表读取数据,(如果直接用execute immediate ‘select ... from ...’,很难返回出结果集,所以采用临时表存放数据)
declare strsql varchar2(3000);
strwhere varchar2(1000);
begin
execute immediate 'truncate table wmedi.wave_distro_filter';
strsql:='insert into wmedi.wave_distro_filter select store_distro.* ' ||
'from store_distro '||
'inner joi