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

Oracle Òì³£

OracleÒì³£·ÖΪ3ÖÖ:
(1)Ô¤¶¨ÒåÒì³£:no_data_foundµÈ,ÊÇOracleϵͳ¶¨ÒåµÄÒì³£.
declare
  s_test varchar2
begin
  select id into s_test from test; --´Ëʱtest±íÎÞÊý¾Ý
exception
  when no_data_found then
    raise_application_error(-20001, 'ûÓÐÊý¾Ý');
end;
(2)×Ô¶¨ÒåÒì³£:×Ô¼º¶¨ÒåµÄÒì³£,×Ô¼ºÅ×,×Ô¼º²¶»ñ.
declare
  exp_test exception;
begin
  if 1 = 1 then
    raise exp_test;
  end if;
exception
  when exp_test then
    raise_application_error(-20002, '×Ô¶¨ÒåÒì³£');
end;
(3)·ÇÔ¤¶¨ÒåÒì³£.
--Õâ¸öÀý×ӾͲ»ÐèÒª×Ô¼ºÅ×,ÒòΪÒѾ­°ÑÖ÷¼ü³åÍ»µÄÒì³£¸ø¸²¸ÇÁË,ËùÒÔÖ»ÒªÊÇÖ÷¼ü³åÍ»,ÄÇô¾ÍÊÇexp_testÀ´´úÌæÒÔÇ°ÄǸöÁË.
declare
  exp_test exception;
  progam exception_init(exp_test ,-1); --¸²¸Ç-1Õâ¸öÒì³£,-1´ú±íÖ÷¼ü³åÍ»
begin
  insert into test values('1');   --test±íµÄÖ÷¼ü´æÔÚ1Õâ¸öÖµ.
exception
  when exp_test then
    raise_application_error(-20003, 'Ö÷¼ü³åÍ»');
end;
ÅжϲÎÊýµÄ.
create or replace procedure addContent_test
(
  s_type in varchar2,
  s_count in number,
  s_language in varchar2
)
is
  exp_type exception;
  exp_count exception;
  exp_language exception;
begin
  if s_type <> 50
  and s_type <> 51
  and s_type <> 52
  and s_type <> 53
  and s_type <> 54
  and s_type <> 55
  and s_type <> 56
  and s_type <> 57
  and s_type <> 0
  and s_type <> 2
  and s_type <> 3
  and s_type <> 99999999 then
    raise exp_type;
  end if;
 
  if s_count < 1 or s_count > 100 then
    raise exp_count;
  end if;
  dbms_output.put_line(to_number(instr(s_language, ',',1,2)));
  if instr(s_language, ',',1,2) > 0 then
    raise exp_language;
  end if;
 
exception


Ïà¹ØÎĵµ£º

oracle EMCAÃüÁî

ÎÒÃÇ¿ÉÄÜÔÚOracle DB10g Öлᾭ³£Óöµ½OEM²»ÄÜÕý³£Ê¹ÓõÄÎÊÌâ,µ¼ÖÂÎÊÌâµÄÔ­Òò²»¾¡Ïàͬ,
µ«×îºó¾ø´ó¶àÊýÎÊÌâ¿ÉÒÔͨ¹ýemca Õâ¸öÃüÁîÀ´½â¾ö,ÏêϸµÄ˵Ã÷¿ÉÒԲ鿴Á¬»ú°ïÖú,
ÏÂÃæ¸ø³öһЩ³£ÓõÄÃüÁî,¼°ÊµÀý²½Öè.
´´½¨Ò»¸öEM×ÊÁÏ¿â
    emca -repos create
Öؽ¨Ò»¸öEM×ÊÁÏ¿â
    emca -repos r ......

Oracle³£¼ûº¯Êý´óÈ«

SQLÖеĵ¥¼Ç¼º¯Êý
1.ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
       A       A    ZERO     SPACE
--------- --------- -- ......

OracleÈÕÆÚº¯Êý¼¯½õ

OracleÈÕÆÚº¯Êý¼¯½õ(Ò»)
Ò»¡¢ ³£ÓÃÈÕÆÚÊý¾Ý¸ñʽ
1.Y»òYY»òYYY ÄêµÄ×îºóһ룬Á½Î»»òÈýλ
SQL> Select to_char(sysdate,'Y') from dual;
TO_CHAR(SYSDATE,'Y')
--------------------
7
SQL> Select to_char(sysdate,'YY') from dual;
TO_CHAR(SYSDATE,'YY')
---------------------
07
SQL> Select to_ch ......

ORACLEÖÐËÑË÷×ÖĸÊý×Ö»ìºÏµÄ×Ö·û´®

SQL> with tt as
  2  (
  3  select 'haha' string from dual union
  4  select '123' from dual union
  5  select 'haha12' from dual union
  6  select 'haha[]' from dual union
  7  select '12@@' from dual union
  8  select ......

Oracle¶à°æ±¾»úÖÆ

Õâ¸öÖ÷ÌâÓë²¢·¢¿ØÖƵĹØϵ·Ç³£½ôÃÜ£¬ÒòΪÕâÕýÊÇOracle²¢·¢¿ØÖÆ»úÖƵĻù´¡£¬Oracle²ÉÓÃÁËÒ»ÖÖ¶à°æ±¾¡¢¶ÁÒ»Ö£¨read-consistent£©µÄ²¢·¢Ä£ÐÍ¡£ÔÙ´Î˵Ã÷£¬ÎÒÃǽ«ÔÚµÚ7Õ¸üÏêϸµØ½éÉÜÓйصļ¼Êõ¡£²»¹ý£¬ÊµÖÊÉϽ²£¬OracleÀûÓÃÕâÖÖ»úÖÆÌṩÁËÒÔÏÂÌØÐÔ£º
q  ¶ÁÒ»Ö²éѯ£º¶ÔÓÚÒ»¸öʱ¼äµã£¨point in time£©£¬²éѯ»á²úÉúÒ»ÖµĽ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ