Oracle ÏÔʽÓαê
--------------------ÏÔʽÓαê
--²éѯÊý¾Ý
select * from employees;
--¶¨Ò岿·Ö
declare
--ÉùÃ÷Óαê
cursor mycur is select * from employees where employee_id<120;
--¶¨ÒåÒ»¸ö¼¯ºÏ±äÁ¿ÓÃÓڴ洢ij¸ö±íµÄÒ»Ìõ¼Ç¼
rowdata employees%rowtype;
--Ö´Ðв¿·Ö
begin
--´ò¿ªÓαê
open mycur;
loop
--ÔÚÑ»·ÖÐÓÃfetchÌáÈ¡¼Ç¼
fetch mycur into rowdata;
dbms_output.put_line('salary:'||rowdata.salary||' '||'hire_date:'||rowdata.hire_date||' '||'first_name:'||rowdata.first_name);
--ÓÃ%notfoundÊôÐÔ¼ì²âÊÇ·ñµ½×îºóÒ»Ìõ¼Ç¼
exit when mycur%notfound;
end loop;
--Ìá½»ÊÂÎñ;
commit;
--¹Ø±ÕÓαê
close mycur;
--Òì³£²¿·Ö
exception
--ÓÐÒì³£Ôò»Ø¹ö
when others then
rollback;
end;
/
--------------------²ÎÊýÓαê
--²éѯÊý¾Ý
select * from employees where salary<=10000;
--¶¨Ò岿·Ö
declare
--¶¨ÒåÓαꣻעÒ⣺²ÎÊýÀàÐÍ(input_salary)²»ÐèÒªÖ¸¶¨¾«¶È
cursor mycur(input_salary number) is select * from employees where salary<input_salary;
--¶¨ÒåÒ»¸ö¼¯ºÏ±äÁ¿ÓÃÓÚ´æ´¢Ä
Ïà¹ØÎĵµ£º
×î½ü×öÁ˸öÏîÄ¿£¬ÊµÏÖ¶Ô´æÔÚǧÍòÌõ¼Ç¼µÄ¿â±í½øÐвåÈë¡¢²éѯ²Ù×÷¡£ÔÒÔΪ¶ÔÊý¾Ý¿âµÄ²åÈë¡¢²éѯÊǼþºÜÈÝÒ×µÄÊ£¬¿É²»Öªµ±Êý¾Ý´ïµ½°ÙÍòÉõÖÁǧÍòÌõ¼¶±ðµÄʱºò£¬ÕâÒ»ÇÐËƺõ±äµÃÏ൱À§ÄÑ¡£¼¸¾ÕÛÌÚ£¬×ÜËãÍê³ÉÁËÈÎÎñ¡£
1¡¢ ±ÜÃâʹÓÃHibernate¿ò¼Ü
HibernateÓÃÆðÀ´ËäÈ»·½±ã£¬µ«¶ÔÓÚº£Á¿Êý¾ÝµÄ²Ù×÷ÏÔµÃÁ¦²»´ÓÐÄ¡£
¹ØÓÚ²åÈ룺
......
PL/SQL µÄÒì³£(Ô¤¶¨ÒåÒì³£)
2009-08-13 20:24
Òì³£Ãû³Æ & ......
linux Ï°²×°oracle ÊÇÒ»¼þºÜÁîÈËÍ·ÌÛµÄÊÂÇ飬ÎÒ°Ñ×Ô¼ºµÄ°²×°²½ÖèÄóöÀ´¸ø´ó¼Ò·ÖÏíһϡ£
Ò».linux·þÎñ¶ËµÄ°²×°.
1.ÏÂÔØoracle·þÎñ¶ËÈí¼þ,ÏÂÔØÍøÖ·ÈçÏÂ
http://www.oracle.com/technology/software/products/database/index.html
ÎÒÑ¡ÔñµÄ°æ±¾ÊÇ£ºOracle Database 10g Release 2 (10.2.0.1.0) for Linux x86-64
......
create or replace procedure aa1 is
v_aa varchar2(20);
v_bb varchar2(20);
va_aa varchar2(20);
va_bb varchar2(20);
va_number_aa number;
message varchar2(60);
CURSOR aas is
SELECT DISTINCT aa.aa, aa.bb from aa;
CURSOR aaas is
SELECT DISTINCT aaa.aa, aaa.bb from aaa where aaa.aa = v_aa ......