oracal中cursor的两种用法

oracal中cursor的两种用法
2007年12月27日 星期四 下午 01:03

1,(for str in cur loop   end loop;)

declare cursor cur_cus1 is select name,sex,ctele,ftele from c03_custmatl where id = trim(v_apid);
begin
   for cus1_rs in cur_cus1 loop
      v_apname:=cus1_rs.name;
      v_apsex:=cus1_rs.sex;
      v_ctele:=cus1_rs.ctele;
      v_ftele:=cus1_rs.ftele;
   end loop;
end;

2,(open cur; loop fetch cur into ...;end loop;close cur;)

declare cursor cur_cus1
   is
     select name,sex,ftele,ctele from e03_custmatl where id = trim(v_apid);
begin
   open cur_cus1;
    loop
      fetch cur_cus1 into v_apname,v_apsex,v_ftele,v_ctele;
      exit when cur_cus1%notfound;
    end loop;
   close cur_cus1;
end;

你可能感兴趣的:(Cursor)