select * from mid_city --贫困县及省表
select code,censusaddr from bd_psndoc --人员表户籍地址字段
declare --v_count int(4); v_sql varchar2(1000); begin for c_cur in( select replace(country,'县') c_country from mid_city where length(country) >2 union all select country from mid_city where length(country) <=2 ) loop v_sql := 'update bd_psndoc set is_flag=''Y'' where censusaddr like ''%'||c_cur.c_country||'%'''; dbms_output.put_line(v_sql); execute immediate v_sql; --commit; end loop; update bd_psndoc set is_flag='N' where is_flag is null; commit; end;