Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

OracleÀ©Õ¹PL/SQL¼ò½é(Áù)

8.    bulk collect /forall
ʹÓÃbulk collect¿ÉÒԳɿéµØ¶ÁÈ¡Êý¾Ý£¬Ëü¿ÉʹSQLÒýÇæÔÚ·µ»ØÊä³ö½á¹û¸øPL/SQLÒýÇæ֮ǰ´óÅú°ó¶¨Êä³ö¼¯ºÏ¡£ÕâÑù¿ÉÒÔÒ»´ÎÐԵذÑÊý¾Ý¶¯Ì¬µØ×°Ôص½¼¯ºÏÖУ¬µ«bulk collectÐèÒª´óÁ¿ÄÚ´æ¡£bulk collect¿ÉÓÃÓÚselect into¡¢fetch intoºÍreturning intoÓï¾äÖС£
¡ñ    select intoÖÐʹÓÃbulk collect
declare
  type t_email is table of employees.email%type;
  v_email_list t_email;
begin
  select email bulk collect
    into v_email_list
    from employees
   where department_id = 50;
  dbms_output.put_line('»ñÈ¡emailµØÖ·Êý£º' || v_email_list.count);
end;
/
»ñÈ¡emailµØÖ·Êý£º45
¡ñ    fetch into ÖÐʹÓÃbulk collect
declare
  type t_emp is table of employees%rowtype;
  v_emp_list t_emp;
  cursor c_emp is
    select * from employees where department_id = 50;
begin
  open c_emp;
  --ÔÚfetch intoÖÐʹÓÃbulk collect
  fetch c_emp bulk collect
    into v_emp_list;
  dbms_output.put_line('»ñÈ¡¹ÍÔ±×ÜÊý£º' || v_emp_list.count);
end;
/
»ñÈ¡¹ÍÔ±×ÜÊý£º45
¡ñ    ÔÚreturning intoÖÐʹÓÃbulk collect
ͨ¹ýʹÓÃreturning×Ó¾äbulk collect¿É·µ»ØÖµ¸øµ÷Óùý³Ì£¬²»ÐèÒª¶îÍâ»ñÈ¡fetchÓï¾ä¡£
--´´½¨²âÊÔ±í
create table emptemp as select * from employees where department_id=50;
--Ö´Ðйý³Ì
declare
  type t_id_list is table of number;
  type t_name_list is table of varchar2(32);
  ids   t_id_list;
  names t_name_list;
begin
  delete from emptemp
   where commission_pct is null
  returning employee_id, first_name bulk collect into ids, names;
  dbms_output.put_line('Deleted ' || sql%rowcount || ' rows:');
  for i in ids.first .. ids.last loop
    dbms_output.put_line('Employees #' || ids(i) || ': ' || names(i));
  end loop;
  commit;
exception
  when others then
    rollback;
end;


Ïà¹ØÎĵµ£º

OracleÓû§¹ÜÀí

 Ò»£¬OracleÊý¾Ý¿âÓû§¼ò½é
 ÔÚOracleÊý¾Ý¿âÖÐÈκζÔÏó¶¼ÊôÓÚÒ»¸öÌض¨Óû§£¬»òÕß˵һ¸öÓû§ÓëͬÃûµÄģʽÏà¹ØÁª¡£
 ÒªÁ¬½Óµ½OracleÊý¾Ý¿âÐèÒªÒ»¸öÓû§ÕÊ»§£¬¸ù¾ÝÐèÒªÊÚÓèµÄ²Ù×÷ȨÏÞ¡£
 1£¬Ä¬ÈÏÊý¾Ý¿âÓû§Ä£Ê½£º
  Sys:Êý¾Ý¿â×ֵ䣨´æ´¢±»¹ÜÀí¶ÔÏóËùÓÐÐÅÏ¢£©ºÍÊÓͼ´æ´¢ÔÚ¸ÃģʽÖС£ÏµÍ³¼¶Óû§¡£ ......

Oracle Cursor

 1£¬Ê²Ã´ÊÇÓαꣿ
 ¢Ù´Ó±íÖмìË÷³ö½á¹û¼¯£¬´ÓÖÐÿ´ÎÖ¸ÏòÒ»Ìõ¼Ç¼½øÐн»»¥µÄ»úÖÆ¡£
   
 ¢Ú¹ØϵÊý¾Ý¿âÖеIJÙ×÷ÊÇÔÚÍêÕûµÄÐм¯ºÏÉÏÖ´Ðеġ£
  ÓÉ SELECT Óï¾ä·µ»ØµÄÐм¯ºÏ°üÀ¨Âú×ã¸ÃÓï¾äµÄ WHERE ×Ó¾äËùÁÐÌõ¼þµÄËùÓÐÐС£ÓɸÃÓï¾ä·µ»ØÍêÕûµÄÐм¯ºÏ½Ð×ö½á¹û¼¯¡£
   &n ......

Oracle ÈýÖÖ¼¯ºÏÊý¾ÝÀàÐ͵ıȽÏ

 Oracle ÈýÖÖ¼¯ºÏÊý¾ÝÀàÐ͵ıȽÏ:
PL/SQLÖÐûÓÐÊý×éµÄ¸ÅÄËûµÄ¼¯ºÏÊý¾ÝÀàÐͺÍÊý×éÊÇÏàËƵġ£ÔÚ7.3ÒÔÇ°µÄ°æ±¾ÖÐÖ»ÓÐÒ»ÖÖ¼¯ºÏ£¬³ÆΪPL/SQL±í£¬ÔÚÕâÖ®ºóÓÖÓÐÁ½ÖÖ¼¯ºÏÊý¾ÝÀàÐÍ:ǶÌ×±íºÍvarray¡£ÆäÖÐvarray¼¯ºÏÖеÄÔªËØÊÇÓÐÊýÁ¿ÏÞÖƵģ¬index_by±íºÍǶÌ×±íÊÇûÓÐÕâ¸öÏÞÖƵġ£index-by±íÊÇÏ¡ÊèµÄ£¬Ò²¾ÍÊÇ˵ϱê¿ÉÒÔ²»Á¬Ðø ......

oracle Ìåϵ½á¹¹

Ç°¼¸ÌìÃæÊÔµÄʱºòÃæÊÔ¹Ù²ÅÎʹýÎÒORACLEµÄÌåϵ½á¹¹£¬ÈÃÎÒÔÚÒ»ÕÅ°×Ö½ÉÏ»­³öÀ´¡£»ØÍ·ÏëÏ뵱ʱ´ðµÃ»¹²»´í£¬´ó²¿·ÖÄÚÈݶ¼ÃèÊö³öÀ´ÁË£¬ºÇºÇ£¬¸Õ²ÅÔÚÍøÉÏ¿´µ½Ò»Æª½²½âORACLEÌåϵ½á¹¹µÄÎÄÕ£¬¾õµÃ²»´í£¬×ª¹ýÀ´´æ×Å£¬½«À´¿ÉÄÜ»áÓõ½¡£
=================================================================================
ÔÚ±¾ÎÄÀ ......

OracleÊý¾Ý¿â½µµÍHWMµÄ¼¸ÖÖ·½·¨

HWMÊÇoracleÖÐblockÓÐûÓÐʹÓõķֽçÏߣ¬Ëü»áËæ×ÅÊý¾ÝµÄinsert¶øÉÏÉý£¬µ«Ëü²¢²»»áËæÊý¾ÝµÄdelete¶øϽµ£¬Òò´ËÈ«±íɨÃèµÄʱ¼ä²¢²»ÒòÊý¾ÝµÄdelete¶ø¼õÉÙ£¬Ïà·´¿ÉÄÜÓÉÓÚ¿éÇå³ý·´¶øÈ«±íɨÃèʱ¼äÔö¼Ó£¬¿ÉÒÔÓÃÏÂÃæ·½·¨µÄÈÎÒ»Ò»ÖÖÀ´½µµÍHWM£º
µÚÒ»ÖÖ£ºshrink
ÊÊÓÃÓÚ10gÒÔºóµÄ°æ±¾£¬Ç°ÌáÊÇÕâ¸ö±í£¬Ë÷Òý£¬ÎﻯÊÓͼ»òÎﻯÊÓͼlogËùÔ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ