oracle 循环 模板
 

create or replace procedure PRO_DelBuildDissRelation as
 Cursor cursor is    select  *  from  students;
   begin

        for item in cursor LOOP

        begin
        --打印学生的属性值 
        dbms_output.put_line(  item.name  );

        end;
 end LOOP;

end PRO_DelBuildDissRelation;

其他模式  直接作为sql 执行的方式:

 

DECLARE
    v_tbname VARCHAR(64);
    v_sql varchar2(3000);
    v_oid varchar(50):='204057546';
BEGIN
    FOR tb IN (select * from all_tables where owner='HHD' AND TABLE_NAME LIKE 'VDW_MD_HHD%') LOOP
        v_tbname:=tb.Table_Name;
        v_sql := 'insert into TMP_HIS_ANS_HHD(TABLENAME,MI_ID,MI_TAR_CLSID,MI_TAR_OID,MI_SHAPE_TYPE,MI_SHAPE_TITLE,MI_SHAPE_LNG,MI_SHAPE_LAT,MI_SHAPE,EDITTIME,EDITUSER,MI_ZOOM,MI_SHAPE_STATE) select '''||v_tbname||''', MI_ID,MI_TAR_CLSID,MI_TAR_OID,MI_SHAPE_TYPE,MI_SHAPE_TITLE,MI_SHAPE_LNG,MI_SHAPE_LAT,MI_SHAPE,EDITTIME,EDITUSER,MI_ZOOM,MI_SHAPE_STATE from '|| tb.owner ||'.'||tb.table_name||' t WHERE T.MI_TAR_OID='||v_oid;
        execute immediate v_sql;
        --dbms_output.put_line(v_sql);
    END LOOP;
END;


 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐