PL/SQLѧϰ±Ê¼ÇÎå
ÓαêÊÇ´ÓÊý¾Ý¿âÖÐÌáÈ¡³öÀ´µÄÊý¾Ý£¬ÒÔÁÙʱ±íµÄÐÎʽ´æ·ÅÔÚÄÚ´æÖУ¬ÔÚÓαêÖÐÓÐÒ»¸öÊý¾ÝÖ¸Õ룬ÔÚ³õʼ״̬ÏÂÖ¸ÏòÊ׼Ǽ£¬ ÀûÓÃfetchÓï¾äÒÆ¶¯¸ÃÖ¸Õ룬´Ó¶ø¶ÔÓαêÖеÄÊý¾Ý½øÐи÷ÖÖ²Ù×÷¡£
1.¶¨ÒåÓαê
cursor ÓαêÃû is selectÓï¾ä;
2.´ò¿ªÓαê
open ÓαêÃû;
3.ÌáÈ¡ÓαêÊý¾Ý
fetch ÓαêÃû into ±äÁ¿Ãû1, ±äÁ¿Ãû2, ....;
»ò
fetch ÓαêÃû into ¼Ç¼ÐͱäÁ¿Ãû;
4.¹Ø±ÕÓαê
close ÓαêÃû;
5.ÓαêµÄÊôÐÔ
%isopen
¸ÃÊôÐÔ±êʶÓαêÊÇ·ñ´ò¿ª£¬Èç¹ûûÓдò¿ªÓαê¾ÍʹÓÃfetchÓï¾ä½«Ìáʾ´íÎó¡£
%isfound
¸ÃÊôÐÔ±êʶһ¸öfetchÓï¾äÊÇ·ñÓÐÖµ£¬ÓÐÖµ·µ»Øtrue£¬·ñÔò·µ»Øfalse¡£
%notfound
¸ÃÊôÐÔÓë%isfoundÏà·´¡£
%rowcount
¸ÃÊôÐÔÓÃÓÚ»ñÈ¡ÓαêµÄÊý¾ÝÐÐÊý¡£
ʾÀý£º
set serveroutput on
declare
tempsal scott.emp.sal%type;
cursor mycursor is
select * from scott.emp
where sal>tempsal;
cursorrecord mycursor%rowtype;
begin
tempsal:=800;
open mycursor;
if mycursor%isopen then
fetch mycursor into cursorrecord;
dbms_output.put_line(to_char(cursorrecord.deptno));
dbms_output.put_line(to_char(mycursor%rowcount));
else
dbms_output.put_line('Óα껹δ´ò¿ª');
end if;
end;
Ïà¹ØÎĵµ£º
a b c&nb ......
Select * from t_user_profile where convert ( varchar ( 21 ),regDate, 120 ) like ' 2008-05-07% ' ±íÃû³Æ£ºt_user_profile ÈÕÆÚ×Ö¶ÎÃû³Æ£ºregDate
Select * from t_user_profile where convert(varchar(21),regDate,120) like '2008-05-07%'< ......
´ËΪתÌù£¬µ«ÊÇ´ÓÁ¬¸öÌû×ÓÖÐÊÕ¼¯¶øÀ´
ÏÂÃæÀ´Ò»Æð¿´¿´ÂÛ̳ÀïµÄÒ»¸öoracle·½ÃæµÄÎÊÌ⣺
====================Question
=========================
jmbdat dayt y &n ......
1¡¢ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_valueÔÚ check_expressionΪNULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë check_expresssion ¾ßÓÐÏàͬµÄÀàÐÍ¡£
·µ»ØÀàÐÍ
·µ»ØÓë check_expression Ï ......
1.³£Á¿
¶¨ÒåÓï·¨¸ñʽ£º
³£Á¿Ãû constant ÀàÐͱêʶ·û [not null]:=Öµ;
È磺PI constant number(9):=3.1415;
2.»ù±¾Êý¾ÝÀàÐͱäÁ¿
»ù±¾Êý¾ÝÀàÐÍ
number Êý×ÖÐÍ
int ÕûÊýÐÍ
pls_integer ÕûÊýÐÍ£¬²úÉúÒç³öʱ³öÏÖ´íÎó
binary_integer ÕûÊýÐÍ£¬±íʾ´ø·ûºÅµÄÕûÊý
char ¶¨³¤×Ö·ûÐÍ£¬×î´ó255¸ö×Ö·û
varchar2 ±ä³¤× ......