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

Oracle´æ´¢¹ý³Ì£¬º¯Êý¡£

--ÔÚÓ¦ÓóÌÐòÖÐÍùÍùÓÐЩ¹Ì¶¨µÄÊý¾Ý¿â²Ù×÷£¬ÎÒÃdz£³£ÎªÖÂл¹Ì¶¨µÄ²Ù×÷¶¨ÒåÁËһЩ´æ´¢¹ý³Ì¡£ÕâЩ´æ´¢¹ý³Ì²»½ö
--¿ÉÒÔ¼ò»¯¿Í»§¶ËµÄÓ¦ÓóÌÐòµÄ¿ª·¢ºÍά»¤¡£¶øÇÒ»¹¿ÉÒÔÌá¸ßÓ¦ÓõÄÔËÐÐÐÔÄÜ¡£
-- ´´½¨´æ´¢¹ý³ÌµÄÓï·¨¡£
create [or replace] procedure <¹ý³ÌÃû>[(²ÎÊý)]
is|as
[¾Ö²¿±äÁ¿ÉùÃ÷]
begin
¿ÉÖ´ÐÐÓï¾ä
exception
Òì³£´¦Àí
end
--ÔÚ¶¨ÒåÖÐ IS|AS ¿ÉÒÔ¸ù¾Ýϰ¹ßÑ¡ÔñIS »òÕßAS ³ýÁ˶¨Ò岿·Ö¡£ÆäÓàµÄÓ﷨ͬPL/SQLµÄÓï·¨¡£

Àý£º ¡£
-- 1 ¢ÙÒ»¸öÎ޲εĴ洢¹ý³Ì¡£

create or replace procedure proc_1--proc_1´æ´¢¹ý³ÌÃû³Æ
is
i number(3);--¶¨Òå±äÁ¿
begin
i:=100;
dbms_output.put_line(i);
end;
--¢Úµ÷Óô洢¹ý³Ì¡£
begin
proc_1;
end;
--Ò»¸öÎÞ²ÎÊýµÄ´æ´¢¹ý³Ì´´½¨Íê±Ï
2 Ò»¸öÓвÎÊýµÄ´æ´¢¹ý³Ì
´æ´¢¹ý³Ì¶¨ÒåµÄʱºò¿ÉÒÔʹÓòÎÊýÒ²¿ÉÒÔ²»ÊµÓòÎÊý¡£

²ÎÊýÀàÐÍ
· ÔÚPL/SQL¹ý³ÌÖУ¬¿ÉÒÔÓÐ3ÖÖÀàÐ͵IJÎÊý¡£
· IN²ÎÊý£º¶ÁÈë²ÎÊý£¬Ö÷³ÌÐòÏò¹ý³ÌÖд«µÝ²ÎÊý¡£
· OUT²ÎÊý£ºÊä³ö²ÎÊý£¬¹ý³ÌÏòÖ÷³ÌÐò´«µÝ²ÎÊý¡£
· IN OUT²ÎÊý£ºÕâ¸ö²ÎÊý£¬¹ý³ÌÓëÖ÷³ÌÐòË«Ïò½»Á÷Êý¾Ý¡£
Èç¹û´æ´¢¹ý³ÌÓÐOUT »òÕßIN OUT ÀàÐ͵IJÎÊý£¬ÄÇô´æ´¢¹ý³Ì¾ÍÖ»ÄÜÔÚPL/SQL
Öб»µ÷Óᣲ»ÄÜʹÓÃEXECUTE »òÕßCALLµ÷Óá£

Ò»¸öÊäÈë²ÎÊýµÄÀý×Ó

create or replace procedure proc_2(myno in number)
is emprow emp%rowtype;--¶¨ÒåÒ»¸öÐÐÀàÐ͵ıäÁ¿
begin
select * into emprow from emp where empno=myno;
dbms_output.put_line('Ô±¹¤ÐÕÃû£º'||emprow.ename||'Ô±¹¤Ð½Ë®'||emprow.sal);
end;
--µ÷ÓÃÕâ¸ö´æ´¢¹ý³Ì
begin
proc_2(7369);
end;

¼ÈÓÐÊäÈë²ÎÊý ÓÖÓÐÊä³ö²ÎÊý

create or replace procedure proc_3(myno in number,mysal out emp.sal%type, myname out emp.ename%type)
is
emprow emp%rowtype;
begin
select sal,ename into mysal,myname from emp where empno=myno;
end;
--µ÷ÓÃÕâ¸ö´æ´¢¹ý³Ì
declare
tempsal emp.sal%type;
empname emp.ename%type;
begin
proc_3(7369,tempsal,empname);
dbms_output.put_line('Ô±¹¤ÐÕÃû'||empname||'Ô±¹¤Ð½Ë®'||tempsal);
end;



Ïà¹ØÎĵµ£º

jdbcÁ¬½ÓOracle

      ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
    ½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
    ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
    Ê×ÏÈ£¬Ô ......

Oracle ±Ê¼Ç


          µÚ1Ò³
 
1. Oracle µÄʹÓÃ
1.1. SQLPLUS µÄÃüÁî
³õʼ»¯±íµÄλÖãº
set
NLS_LANG=american_america.us7ascii  (ÉèÖñàÂë²Å¿ÉÒÔʹÓÃÏÂÃæ½Å±¾)
cd
$ORACLE_HOME/rdbms   cd demo     summit2.sql
********* ......

oracle 10gÊý¾Ý¿â±¸·ÝÓ뻹ԭ×ܽá(×ªÔØ£©

1.Êý¾Ý¿â¹éµµÄ£Ê½:
        * ·Ç¹éµµÄ£Ê½:µ±Êý¾Ý¿âÊý¾ÝÖ»¶Á²»»á¸Ä±äʱ,Êý¾Ý²»»á¸Ä±ä,Êý¾Ý¿âÊʺÏÓ÷ǹ鵵ģʽ,                     ÕâÑùÌá¸ßÐÔÄÜ
    &nb ......

ORACLE ͨ¹ýÓαêʹÓÃÀ´Á˽âcursor µÄºÃ´¦£¡

ÓÐÁËÓα꣬¾Í¿ÉÒÔ²»ÓÃÿÌõÊý¾ÝÈ¥¼ì²éÊÇ·ñ·ûºÏÌõ¼þ£¬ÏÈ¿´Ò»ÏÂÏÂÃæµÄ£º
--ÓαêʹÓã¨ÓαêÆäʵÊÇÒ»¸ö·ÅÈëÄÚ´æÁÙʱ±í£©
declare
   money cms3_simcard.card_fee%type :=0; --¶¨ÒåÓë±í×Ö¶ÎÏàͬÀàÐÍ
   cursor mycursor is --¶¨ÒåÓαê
          select ......

oracle imp/exp ÃüÁîÓ÷¨

OracleÊý¾Ýµ¼Èëµ¼³öimp/exp¾ÍÏ൱ÓÚoracleÊý¾Ý»¹Ô­Ó뱸·Ý¡£expÃüÁî¿ÉÒÔ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öµ½±¾µØµÄdmpÎļþ£¬impÃüÁî¿ÉÒÔ°ÑdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶´¦µÄÊý¾Ý¿â·þÎñÆ÷ÖС£ ÀûÓÃÕâ¸ö¹¦ÄÜ¿ÉÒÔ¹¹½¨Á½¸öÏàͬµÄÊý¾Ý¿â£¬Ò»¸öÓÃÀ´²âÊÔ£¬Ò»¸öÓÃÀ´ÕýʽʹÓá£
 
Ö´Ðл·¾³£º¿ÉÒÔÔÚSQLPLUS.EXE»òÕßDOS£¨ÃüÁîÐУ©ÖÐÖ´ÐУ¬
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ