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
Ïà¹ØÎĵµ£º
ÀûÓÃTOADʵÏÖEXCELÊý¾ÝÔÚoracleµÄµ¼Èëµ¼³ö
1.´ÓORACLEÊý¾Ý¿âµ¼³ö³ÉΪEXCELÎļþ
ÀûÓÃTOADÁ¬½ÓÉÏÊý¾Ý¿â£¬·ÃÎÊij¸ö±í£¬ÎÒ±¾»úÊÇÑ¡Öбí“OA_USER”
ÓÒ¼ü“Save as...”
ΪÁ˽â¾öÖÐÎÄÂÒÂëÎÊÌ⣬ËùÒÔÑ¡ÔñÀàÐÍΪ"XLS Instance"£¬Èç¹û´æÔÚ³¤Êý×ÖÐÍ×Ö·û´®±»¸Ä±äµÄÎÊÌ⣬
ÇëÑ¡ÖГString Fields as S ......
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 ......
DATEÊý¾ÝÀàÐÍ
¡¡¡¡Õâ¸öÊý¾ÝÀàÐÍÎÒÃÇʵÔÚÊÇÌ«ÊìϤÁË£¬µ±ÎÒÃÇÐèÒª±íʾÈÕÆÚºÍʱ¼äµÄ»°¶¼»áÏëµ½dateÀàÐÍ¡£Ëü¿ÉÒÔ´æ´¢Ô£¬Ä꣬ÈÕ£¬ÊÀ¼Í£¬Ê±£¬·ÖºÍÃë¡£ËüµäÐ͵ØÓÃÀ´±íʾʲ ôʱºòÊÂÇéÒѾ·¢Éú»ò½«Òª·¢Éú¡£DATEÊý¾ÝÀàÐ͵ÄÎÊÌâÔÚÓÚËü±íʾÁ½¸öʼþ·¢Éúʱ¼ä¼ä¸ôµÄ¶ÈÁ¿Á£¶ÈÊÇÃë¡£Õâ¸öÎÊÌ⽫ÔÚÎÄÕÂÉÔºóÌÖÂÛtimestampµÄʱ ºò±»½â¾ö¡£¿ÉÒ ......
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 ......
Ëùν³öÓÚjob¶øÊ¤ÓÚjob£¬ËµµÄ¾ÍÊÇOracle 10gºóµÄÐÂÌØÐÔSchedulerÀ²¡£ÔÚ10g»·¾³ÖУ¬ORACLE½¨ÒéʹÓÃSchedulerÌæ»»ÆÕͨµÄjob£¬À´¹ÜÀíÈÎÎñµÄÖ´ÐС£Æäʵ£¬½«SchedulerÃèÊö³É¹ÜÀíjobµÄ¹¤¾ßÒѾ̫¹ýÆ¬ÃæÁË£¬10G°æ±¾ÖÐÐÂÔöµÄScheduler¾ø²»½ö½öÊÇ´´½¨ÈÎÎñÕâô¼òµ¥¡£¡£¡£¡£
Ìáʾ£ºORACLEÖйÜÀíSchedulerÊÇͨ¹ýDBMS_SCHEDULER°ü£¬ ......