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

Oracle Decodeº¯ÊýµÄÓ÷¨

DECODEº¯ÊýÊÇORACLE PL/SQLÊǹ¦ÄÜÇ¿´óµÄº¯ÊýÖ®Ò»£¬Ä¿Ç°»¹Ö»ÓÐORACLE¹«Ë¾µÄSQLÌṩÁ˴˺¯Êý£¬ÆäËûÊý¾Ý¿â³§É̵ÄSQLʵÏÖ»¹Ã»Óд˹¦ÄÜ¡£DECODEÓÐʲôÓÃÍ¾ÄØ£¿ Ïȹ¹ÔìÒ»¸öÀý×Ó£¬¼ÙÉèÎÒÃÇÏë¸øÖÇÐÇÖ°Ô±¼Ó¹¤×Ê£¬Æä±ê×¼ÊÇ£º¹¤×ÊÔÚ8000ÔªÒÔϵĽ«¼Ó20£¥£»¹¤×ÊÔÚ8000ÔªÒÔÉϵļÓ15£¥£¬Í¨³£µÄ×ö·¨ÊÇ£¬ÏÈÑ¡³ö¼Ç¼ÖеŤ×Ê×Ö¶ÎÖµ? select salary into var-salary from employee£¬È»ºó¶Ô±äÁ¿var-salaryÓÃif-then-else»òchoose caseÖ®ÀàµÄÁ÷¿ØÖÆÓï¾ä½øÐÐÅжϡ£ Èç¹ûÓÃDECODEº¯Êý£¬ÄÇôÎÒÃǾͿÉÒÔ°ÑÕâЩÁ÷¿ØÖÆÓï¾äÊ¡ÂÔ£¬Í¨¹ýSQLÓï¾ä¾Í¿ÉÒÔÖ±½ÓÍê³É¡£ÈçÏ£ºselect decode(sign(salary - 8000),1,salary*1.15,-1,salary*1.2,salary from employee ÊDz»ÊǺܼò½à£¿ DECODEµÄÓï·¨£ºDECODE(value,if1,then1,if2,then2,if3,then3,...,else)£¬±íʾÈç¹ûvalueµÈÓÚif1ʱ£¬DECODEº¯ÊýµÄ½á¹û·µ»Øthen1,...,Èç¹û²»µÈÓÚÈκÎÒ»¸öifÖµ£¬Ôò·µ»Øelse¡£³õ¿´Ò»Ï£¬DECODE Ö»ÄÜ×öµÈÓÚ²âÊÔ£¬µ«¸Õ²ÅÒ²¿´µ½ÁË£¬ÎÒÃÇͨ¹ýһЩº¯Êý»ò¼ÆËãÌæ´úvalue£¬ÊÇ¿ÉÒÔʹDECODEº¯Êý¾ß±¸´óÓÚ¡¢Ð¡ÓÚ»òµÈÓÚ¹¦ÄÜ¡£ decode()º¯ÊýʹÓü¼ÇÉ ·Èí¼þ»·¾³: 1¡¢Windows NT4.0+ORACLE 8.0.4 2¡¢ORACLE°²×°Â·¾¶Îª:C:\ORANT ·º¬Òå½âÊÍ: decode(Ìõ¼þ,Öµ1,·­ÒëÖµ1,Öµ2,·­ÒëÖµ2,...Öµn,·­ÒëÖµn,ȱʡֵ) ¸Ãº¯ÊýµÄº¬ÒåÈçÏÂ: IF Ìõ¼þ=Öµ1 THEN RETURN(·­ÒëÖµ1) ELSIF Ìõ¼þ=Öµ2 THEN RETURN(·­ÒëÖµ2) ...... ELSIF Ìõ¼þ=Öµn THEN RETURN(·­ÒëÖµn) ELSE RETURN(ȱʡֵ) END IF · ʹÓ÷½·¨: 1¡¢±È½Ï´óС select decode(sign(±äÁ¿1-±äÁ¿2),-1,±äÁ¿1,±äÁ¿2) from dual; --È¡½ÏСֵ sign()º¯Êý¸ù¾Ýij¸öÖµÊÇ0¡¢ÕýÊý»¹ÊǸºÊý£¬·Ö±ð·µ»Ø0¡¢1¡¢-1 ÀýÈç: ±äÁ¿1=10£¬±äÁ¿2=20 Ôòsign(±äÁ¿1-±äÁ¿2)·µ»Ø-1£¬decode½âÂë½á¹ûΪ¡°±äÁ¿1¡±£¬´ïµ½ÁËÈ¡½ÏСֵµÄÄ¿µÄ¡£ 2¡¢±í¡¢ÊÓͼ½á¹¹×ª»¯ ÏÖÓÐÒ»¸öÉÌÆ·ÏúÊÛ±ísale£¬±í½á¹¹Îª: month char(6) --ÔÂ·Ý sell number(10,2) --ÔÂÏúÊÛ½ð¶î ÏÖÓÐÊý¾ÝΪ: 200001 1000 200002 1100 200003 1200 200004 1300 200005 1400 200006 1500 200007 1600 200101 1100 200202 1200 200301 1300 ÏëҪת»¯ÎªÒÔϽṹµÄÊý¾Ý: year char(4) --Äê·Ý month1 number(10,2) --1ÔÂÏúÊÛ½ð¶î month2 number(10,2) --2ÔÂÏúÊÛ½ð¶î month3 number(10,2) --3ÔÂÏúÊÛ½ð¶î month4 number(10,2) --4ÔÂÏúÊÛ½ð¶î month5 number(10,2) --


Ïà¹ØÎĵµ£º

oracleÖе÷Óôø²ÎÊýµÄ´æ´¢¹ý³Ì

create or replace procedure proc_test
( a in number, b out number )
as
begin
b:=a+1;
end    proc_test;
ÏÖÔÚÒªµ÷Óõϰ¾ÍÊÇÕâÑù
SQL> c number;
SQL>exec proc_test(1,:c);
ǧÍòҪעÒâ±ðÍüÁËдðºÅ ......

ÓÃsqlplusΪoracle´´½¨Óû§ºÍ±í¿Õ¼ä


 ÓÃOracle9i×Ô´øµÄÆóÒµ¹ÜÀíÆ÷»òPL/SQLͼÐλ¯µÄ·½·¨´´½¨±í¿Õ¼äºÍÓû§ÒÔ¼°·ÖÅäȨÏÞÊÇÏà¶Ô±È½Ï¼òµ¥µÄ£¬±¾ÎÄÒª½éÉܵÄÊÇÁíÒ»ÖÖ·½·¨£¬Ê¹ÓÃOracle 9iËù´øµÄÃüÁîÐй¤¾ß£ºSQLPLUSÀ´´´½¨±í¿Õ¼ä£¬Õâ¸ö·½·¨ÓÃÆðÀ´¸ü¼Ó¼òÃ÷¿ì½Ý¡£
       
        ¼ÙÉè ......

ÈçºÎ½â¾ö¾ÖÓòÍøÖÐWindows·À»ðǽ²»ÄÜ·ÃÎÊOracleÎÊÌâ!


Èç¹ûÄãÊÇWINXP»òWIN2003µÄϵͳÖÐ×Ô´øµÄ·À»ðǽ,¿ÉÒÔÊÔÒ»ÏÂÒÔÏ·½·¨:
1.ÔÚ·À»ðǽµÄÀýÍâÖÐ,Ìí¼ÓORACLE.EXEÔËÐгÌÐò.(ÔÚoracle°²×°Ä¿Â¼ÕÒµ½binÎļþ¼ÐÖÐ)
2.ÔÙÔÚ·À»ðǽÀýÍâÖУ¬Ìí¼Ó¶Ë¿Ú1521¶Ë¿Ú¾ÍÑù¾ÖÓòÍøÄ򵀮äËû»úÆ÷¾Í¿ÉÒÔ·ÃÎÊÄãµÄORACLEÁË.
»òÕßÔڸ߼¶ÖÐ,Ñ¡Öе±Ç°Ê¹ÓõÄÍø¿¨,Ìí¼ÓIP,¶Ë¿ÚºÅ(1521),ÕâÑù,ÆäËû»úÆ÷Ò²¿ÉÒÔ·ÃÎ ......

oracleËÀËøµÄ¼ì²â¼°´¦Àí

Ò». ËÀËøµÄ¼ì²â
   --²éËÀËøµÄ»á»°¡£
select  A.sid, b.serial#,
 decode(A.type,
    'MR', 'Media Recovery',
    'RT','Redo Thread',
    'UN','User Name',
    'TX', 'Transaction',
    'TM', ' ......

oracle³£ÓÃÃüÁî

ORACLE³£ÓÃÃüÁî
Ò»¡¢ORACLEµÄÆô¶¯ºÍ¹Ø±Õ
1¡¢ÔÚµ¥»ú»·¾³ÏÂ
ÒªÏëÆô¶¯»ò¹Ø±ÕORACLEϵͳ±ØÐëÊ×ÏÈÇл»µ½ORACLEÓû§£¬ÈçÏÂ
su - oracle
a¡¢Æô¶¯ORACLEϵͳ
oracle>svrmgrl
SVRMGR>connect internal
SVRMGR>startup
SVRMGR>quit
b¡¢¹Ø±ÕORACLEϵͳ
oracle>svrmgrl
SVRMGR>connect&nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ