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

oracle CursorʹÓôóÈ«

ʹÓÃCursor:
--²âÊÔһϣ¬½ñÌì²ÅÉêÇëʹÓÃitpub.net µÄblog
declare
RoomID Room.RoomID%Type;
RoomName Room.RoomName%Type;
cursor crRoom is
select RoomID,RoomName
from Room;
begin
open crRoom;loop;
fetch crRoom into RoomID,RoomName;
exit when crRoom%notFound;
end loop;
close crRoom;
end;
 
3.1ÔÚÓαêʹÓÃÈë¿Ú²ÎÊý
ÔÚSQLÓï¾äµÄWhere ×Ó¾äÖÐÇ¡µ±Ê¹Óà Ïà¹ØÓï¾ä¼ò»¯Âß¼­£¬±¾À´ÐèҪʹÓÃÁ½¸öÓα꣬°ÑÏà¹ØÈë¿Ú²ÎÊý·ÅÈëµ½SQLÓï¾äµÄWhere ×Ó¾äÖУ¬Ò»¸ö¾Í¸ã¶¨ÁË£º
cursor crRoom is
select
distinct Â¥²ã,·¿ÎÝÓÃ;
from TT_ûÓд¦ÀíµÄ·¿ÎÝ t
where Êý¾Ý¼¶±ð>= 0 and ·¿ÎÝ´¦ÀíÀà±ð= 3 and ²úȨ±àºÅ=p_²úȨ±àºÅ
and ²ðǨ·¿ÎÝÀà±ð=p_²ðǨ·¿ÎÝÀà±ð
and Ãæ»ý>0 and (not p_·¿ÎÝÓÃ; is null
and ·¿ÎÝÓÃ;=p_·¿ÎÝÓÃ;
or p_·¿ÎÝÓÃ; is null);
ÁíÍâÒ»¸öÀý×Ó£º
CREATE OR REPLACE PROCEDURE PrintStudents(
p_Major IN students.major%TYPE) AS
CURSOR c_Students IS
SELECT first_name, last_name
from students
WHERE major = p_Major;
BEGIN
FOR v_StudentRec IN c_Students LOOP
DBMS_OUTPUT.PUT_LINE(v_StudentRec.first_name || ' ' ||
v_StudentRec.last_name);
END LOOP;
END;
 
Oracle´øµÄÀý×Óexamp6.sql
DECLARE CURSOR bin_cur(part_number NUMBER) IS SELECT amt_in_bin
from bins
WHERE part_num = part_number AND
amt_in_bin > 0 ORDER BY bin_num
FOR UPDATE OF amt_in_bin;
bin_amt bins.amt_in_bin%TYPE;
total_so_far NUMBER(5) := 0;
amount_needed CONSTANT NUMBER(5) := 1000;
bins_looked_at NUMBER(3) := 0;
BEGIN
OPEN bin_cur(5469);
WHILE total_so_far < amount_needed LOOP
FETCH bin_cur INTO bin_amt;
EXIT WHEN bin_cur%NOTFOUND;
/* If we exit, there's not enough to *
* satisfy the order. */ bins_looked_at := bins_looked_at + 1;
IF total_so_far + bin_amt < amount_needed THEN
UPDATE bins SET amt_in_bin = 0 WHERE CURRENT OF bin_cur;
-- take everything in the bin total_so_far := total_so_far + bin_amt;
ELSE -- we finally have enough UPDATE bins SET amt_in_bin = amt_in_bin
- (amount_needed - total_so_far)
WHERE CURRENT OF bin_cur;
total_so_far := amount_needed;
END IF;
END L


Ïà¹ØÎĵµ£º

OracleÍⲿ±íСÀý

1)½¨Á¢²Ù×÷ϵͳĿ¼e:\test£¬×¼±¸Êý¾ÝÎļþdept.txt²¢ÖÃÓÚe:\testÖ®ÏÂ
"10","ACCOUNTING","NEW
YORK"
"20","RESEARCH","DALLAS"
"30","SALES","CHICAGO"
"40","OPERATIONS","BOSTON"
2)´´ ......

Oracle֪ʶ£¨¶þ£©

 
OracleÊý¾Ý¿âº¯Êý£¨µ¥Ðк¯Êý£©
 
OracleÖеĺ¯ÊýºÍCÖеĺ¯Êý²î²»¶à£¬Ò²ÊÇÓк¯ÊýÃû£¬²ÎÊý±í£¬ºÍ·µ»ØÖµÀàÐÍ×é³ÉµÄ£¬µ¥Ðк¯Êý£¬ÊÇÕë¶ÔÿÌõ¼Ç¼¶¼ÓÐÒ»¸ö½á¹û¡£µ¥Ðк¯Êý¿ÉÒÔ³öÏÖÔÚselect ºóÃ棬Ҳ¿ÉÒÔ³öÏÖÔÚwhere×Ó¾äÖС£
 
ÐèÒª´¦ÀíÏÖʵµÄ½á¹ûʱ£¬¾Í°Ñº¯ÊýдÔÚselectºóÃ棬ÓÃÓÚÌõ¼þ¹ýÂËʱ£¬¾Í°Ñº¯Êý ......

OracleÊý¾Ý¿âΪʲô±äÂýÁË£¿

±¾Îijö×Ô¡¶Íø¹ÜÔ±ÊÀ½ç¡·20002ÄêµÚ8ÆÚ“¹ÊÕÏÕï¶Ï”À¸Ä¿
Ó²¼þ»·¾³£º SUN250·þÎñÆ÷£¬1G CPU , 512M Ram , 18G SCSIÓ²ÅÌ
ϵͳ»·¾³£º SUN Solaris 2.7
·þÎñ»·¾³£º Oracle 8.1.6
ÖÜÎåÎÒ·¢ÏÖOracleÊý¾Ý¿âÔÚÖ´ÐгÌÐòʱµÄÏìÓ¦ÌرðÂý£¬Õû¸öÊý¾Ý¿â·þÎñËùÔÚµÄSUN Solaris 2.7ϵͳҲÊÇÕâÑù£¬ÎÞÂÛÔËÐÐʲô³ÌÐò¶¼±ÈÍù³£ÂýÁ˺ ......

Oracle ·ÖÇø±í

Oracle ·ÖÇø±í
OracleÌṩÁË·ÖÇø¼¼ÊõÒÔÖ§³ÖVLDB(Very Large DataBase)¡£·ÖÇø±íͨ¹ý¶Ô·ÖÇøÁеÄÅжϣ¬°Ñ·ÖÇøÁв»Í¬µÄ¼Ç¼£¬·Åµ½²»Í¬µÄ·ÖÇøÖС£·ÖÇøÍêÈ«¶ÔÓ¦ÓÃ͸Ã÷¡£
OracleµÄ·ÖÇø±í¿ÉÒÔ°üÀ¨¶à¸ö·ÖÇø£¬Ã¿¸ö·ÖÇø¶¼ÊÇÒ»¸ö¶ÀÁ¢µÄ¶Î£¨SEGMENT£©£¬¿ÉÒÔ´æ·Åµ½²»Í¬µÄ±í¿Õ¼äÖС£²éѯʱ¿ÉÒÔͨ¹ý²éѯ±íÀ´·ÃÎʸ÷¸ö·ÖÇøÖеÄÊý¾Ý£¬Ò²¿ÉÒÔ ......

Oracle substr ºÍ instr µÄÓ÷¨

INSTR·½·¨µÄ¸ñʽΪ
INSTR(Ô´×Ö·û´®, Ä¿±ê×Ö·û´®, ÆðʼλÖÃ, Æ¥ÅäÐòºÅ)
ÀýÈ磺INSTR('CORPORATE FLOOR','OR', 3, 2)ÖУ¬Ô´×Ö·û´®Îª'CORPORATE FLOOR', Ä¿±ê×Ö·û´®Îª'OR'£¬ÆðʼλÖÃΪ3£¬È¡µÚ2¸öÆ¥ÅäÏîµÄλÖá£
ĬÈϲéÕÒ˳ÐòΪ´Ó×óµ½ÓÒ¡£µ±ÆðʼλÖÃΪ¸ºÊýµÄʱºò£¬´ÓÓұ߿ªÊ¼²éÕÒ¡£
ËùÒÔSELECT INSTR('CORPORATE FLOOR' ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ