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

oracle cursor ÓαêÓ÷¨

Óα꣺
ÓÃÀ´²éѯÊý¾Ý¿â£¬»ñÈ¡¼Ç¼¼¯ºÏ£¨½á¹û¼¯£©µÄÖ¸Õ룬¿ÉÒÔÈÿª·¢ÕßÒ»´Î·ÃÎÊÒ»Ðнá¹û¼¯£¬ÔÚÿÌõ½á¹û¼¯ÉÏ×÷²Ù×÷¡£
·ÖÀࣺ
¾²Ì¬Óα꣺
·ÖΪÏÔʽÓαêºÍÒþʽÓαꡣ
REFÓα꣺
ÊÇÒ»ÖÖÒýÓÃÀàÐÍ£¬ÀàËÆÓÚÖ¸Õë¡£
ÏÔʽÓα꣺
 CURSOR ÓαêÃû ( ²ÎÊý ) [·µ»ØÖµÀàÐÍ] IS
  Select Óï¾ä
ÉúÃüÖÜÆÚ£º
1.´ò¿ªÓαê(OPEN)
½âÎö£¬°ó¶¨¡£¡£¡£²»»á´ÓÊý¾Ý¿â¼ìË÷Êý¾Ý
2.´ÓÓαêÖлñÈ¡¼Ç¼(FETCH INTO)
Ö´Ðвéѯ£¬·µ»Ø½á¹û¼¯¡£Í¨³£¶¨Òå¾ÖÓò±äÁ¿×÷Ϊ´ÓÓαê»ñÈ¡Êý¾ÝµÄ»º³åÇø¡£
3.¹Ø±ÕÓαê(CLOSE)
Íê³ÉÓα괦Àí£¬Óû§²»ÄÜ´ÓÓαêÖлñÈ¡ÐС£»¹¿ÉÒÔÖØдò¿ª¡£
Ñ¡Ï²ÎÊýºÍ·µ»ØÀàÐÍ
set serveroutput on
declare
 cursor emp_cur ( p_deptid in number) is
select * from employees where department_id = p_deptid;
l_emp employees%rowtype;
begin
 dbms_output.put_line('Getting employees from department 30');
open emp_cur(30);
 loop
  fetch emp_cur into l_emp;
  exit when emp_cur%notfound;
  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');
  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);
 end loop;
 close emp_cur;
 dbms_output.put_line('Getting employees from department 90');
open emp_cur(90);
 loop
  fetch emp_cur into l_emp;
  exit when emp_cur%notfound;
  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');
  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);
 end loop;
 close emp_cur;
end;
/
ÒþʽÓα꣺
²»ÓÃÃ÷È·½¨Á¢Óαê±äÁ¿£¬·ÖÁ½ÖÖ£º
1.ÔÚPL/SQLÖÐʹÓÃDMLÓïÑÔ£¬Ê¹ÓÃORACLEÌṩµÄÃûΪSQLµÄÒþʾÓαê
2.CURSOR FOR LOOP£¬ÓÃÓÚfor loop Óï¾ä
1¾ÙÀý£º
declare
begin
 update departments set department_name=department_name;
 --where 1=2;
 
 dbms_output.put_line('update '|| sql%rowcount ||' records');
end;
/
2¾ÙÀý£º
declare
begin
 for my_dept_rec in ( select department_name, department_id from departments)
 loop
  dbms_output.put_line(my_dept_rec.department_id || ' : ' || my_dept_rec.department_name);
 end lo


Ïà¹ØÎĵµ£º

sql serverºÍoracleµÄÇø±ð

1£®OracleΪ¿Í»§¶Ë¿ªÆô»á»°ÓÐÁ½ÖÖ·½Ê½£º¹²Ïí·þÎñºÍרÓ÷þÎñ¡£ÔÚרÓ÷þÎñÇé¿öÏ£¬¼àÌýÆ÷ΪÁ¬½ÓÇëÇó´´½¨Ð½ø³Ì£¨Unix»·¾³ÏÂÊÇProcess£¬WindowsÏÂÎÒÏëÓ¦¸ÃÊÇThread°É£©£»¹²Ïí·þÎñÇé¿öÏ£¬¼àÌýÆ÷½«¿Í»§ÇëÇ󽻸øDispatcher£¬ÓÉDispatcher°²ÅŶà¿Í»§µÄ×÷Òµ¡£SQL ServerÔÚĬÈÏÇé¿öÏÂ×Ô¶¯Îª¿Í»§¶ËÁ¬½Ó´´½¨Ị̈߳¬µ±Óзdz£¶àµÄ¿Í ......

OracleÊý¾Ý¿âµÄ±¸·ÝÓë»Ö¸´

OracleÊý¾Ý¿âÓÐÈýÖÖ±ê×¼µÄ±¸·Ý·½·¨£¬ËüÃÇ·Ö±ðÊǵ¼³ö£¯µ¼È루EXP/IMP£©¡¢Èȱ¸·ÝºÍÀ䱸·Ý¡£µ¼³ö±¸¼þÊÇÒ»ÖÖÂß¼­±¸·Ý£¬À䱸·ÝºÍÈȱ¸·ÝÊÇÎïÀí±¸·Ý¡£
Ò»¡¢ µ¼³ö£¯µ¼È루Export£¯Import£©
ÀûÓÃExport¿É½«Êý¾Ý´ÓÊý¾Ý¿âÖÐÌáÈ¡³öÀ´£¬ÀûÓÃImportÔò¿É½«ÌáÈ¡³öÀ´µÄÊý¾ÝËͻص½OracleÊý¾Ý¿âÖÐÈ¥¡£
£±¡¢ ¼òµ¥µ¼³öÊý¾Ý£¨Export£©ºÍµ¼ÈëÊý¾ ......

oracleѧϰ±Ê¼Ç2 ±íµÄ»ù±¾²Ù×÷

Oracle±íµÄ¹ÜÀí
±íÃûºÍÁÐÃûµÄÃüÃû¹æÔò£º
1±ØÐëÒÔ×Öĸ¿ªÍ·
2³¤¶È²»Äܳ¬¹ý30¸ö×Ö·û
3²»ÄÜʹÓÃOracleµÄ±£Áô×Ö
4Ö»ÄÜʹÓÃÈçÏÂ×Ö·û£ºA-Z,a-z,0-9,$,#µÈ
OracleÖ§³ÖµÄÊý¾ÝÀàÐÍ£º
1char ¶¨³¤£¬×î´ó2000×Ö·û
Àý×Ó£ºchar(10) ‘Ïþ»Ô’ Ç°Ëĸö×Ö·û·Å’Ïþ»Ô’£¬ºóÌíÁù¸ö¿Õ¸ñ²¹È«
2varchar2(20) ±ä³¤£¬×î´ ......

Oracle×ܽá

Ò».OracleÊý¾Ý¿âÖг£ÓõÄÊý¾ÝÀàÐÍ
varchar2(³¤¶È)¿É±ä³¤×Ö·û´®
char(³¤¶È) ¶¨³¤
number()±íʾÕûÊý»òÕ߸¡µãÊýnumber(8) number(8,2)
clog ×Ö·ûµÄ´ó¶ÔÏó
blog ¶þ½øÖƵĴó¶ÔÏó
¶þ.Êý¾Ý¿â²éѯ
1£©SELECTÓï¾ä
´Ó±íÖÐÌáÈ¡²éѯÊý¾Ý.Ó﷨ΪSELECT [DISTINCT] {column1,column2,…} from tablename WHERE {con ......

OracleµÄͬÒå´Ê£¨synonyms£©×ܽá

oracleµÄͬÒå´Ê×ܽ᣺
¡¡¡¡´Ó×ÖÃæÉÏÀí½â¾ÍÊDZðÃûµÄÒâ˼£¬ºÍÊÔͼµÄ¹¦ÄÜÀàËÆ¡£¾ÍÊÇÒ»ÖÖÓ³Éä¹Øϵ¡£
¡¡¡¡1.´´½¨Í¬Òå´ÊÓï¾ä£º
¡¡¡¡create public synonym table_name for user.table_name;
¡¡¡¡ÆäÖеÚÒ»¸öuser_tableºÍµÚ¶þ¸öuser_table¿ÉÒÔ²»Ò»Ñù¡£
¡¡¡¡´ËÍâÈç¹ûÒª´´½¨Ò»¸öÔ¶³ÌµÄÊý¾Ý¿âÉϵÄijÕűí ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ