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

oracle ´æ´¢¹ý³ÌµÄ»ù±¾Óï·¨ ¼°×¢ÒâÊÂÏî

1.»ù±¾½á¹¹
CREATE OR REPLACE PROCEDURE ´æ´¢¹ý³ÌÃû×Ö
(
    ²ÎÊý1 IN NUMBER,
    ²ÎÊý2 IN NUMBER
) IS
±äÁ¿1 INTEGER :=0;
±äÁ¿2 DATE;
BEGIN
END ´æ´¢¹ý³ÌÃû×Ö
2.SELECT INTO STATEMENT
  ½«select²éѯµÄ½á¹û´æÈëµ½±äÁ¿ÖУ¬¿ÉÒÔͬʱ½«¶à¸öÁд洢¶à¸ö±äÁ¿ÖУ¬±ØÐëÓÐÒ»Ìõ
  ¼Ç¼£¬·ñÔòÅ׳öÒì³£(Èç¹ûûÓмǼÅ׳öNO_DATA_FOUND)
  Àý×Ó£º
  BEGIN
  SELECT col1,col2 into ±äÁ¿1,±äÁ¿2 from typestruct where xxx;
  EXCEPTION
  WHEN NO_DATA_FOUND THEN
      xxxx;
  END;
  ...
3.IF ÅжÏ
  IF V_TEST=1 THEN
    BEGIN
       do something
    END;
  END IF;
4.while Ñ­»·
  WHILE V_TEST=1 LOOP
  BEGIN
 XXXX
  END;
  END LOOP;
5.±äÁ¿¸³Öµ
  V_TEST := 123;
6.ÓÃfor in ʹÓÃcursor
  ...
  IS
  CURSOR cur IS SELECT * from xxx;
  BEGIN
 FOR cur_result in cur LOOP
  BEGIN
   V_SUM :=cur_result.ÁÐÃû1+cur_result.ÁÐÃû2
  END;
 END LOOP;
  END;
7.´ø²ÎÊýµÄcursor
  CURSOR C_USER(C_ID NUMBER) IS SELECT NAME from USER WHERE TYPEID=C_ID;
  OPEN C_USER(±äÁ¿Öµ);
  LOOP
 FETCH C_USER INTO V_NAME;
 EXIT FETCH C_USER%NOTFOUND;
    do something
  END LOOP;
  CLOSE C_USER;
8.ÓÃpl/sql developer debug
  Á¬½ÓÊý¾Ý¿âºó½¨Á¢Ò»¸öTest WINDOW
  ÔÚ´°¿ÚÊäÈëµ÷ÓÃSPµÄ´úÂë,F9¿ªÊ¼debug,CTRL+Nµ¥²½µ÷ÊÔ
¹ØÓÚoracle´æ´¢¹ý³ÌµÄÈô¸ÉÎÊÌⱸÍü
1.ÔÚoracleÖУ¬Êý¾Ý±í±ðÃû²»ÄܼÓas£¬È磺
select a.appname from appinfo a;-- ÕýÈ·
select a.appname from appinfo as a;-- ´íÎó
 Ò²Ðí£¬ÊÇźÍoracleÖеĴ洢¹ý³ÌÖеĹؼü×Öas³åÍ»µÄÎÊÌâ°É
2.ÔÚ´æ´¢¹ý³ÌÖУ¬selectijһ×Ö¶Îʱ£¬ºóÃæ±ØÐë½ô¸úinto£¬Èç¹ûselectÕû¸ö¼Ç¼£¬ÀûÓÃÓαêµÄ»°¾ÍÁíµ±±ðÂÛÁË¡£
  select af.keynode into kn from APPFOUNDATION af where af.appid=aid and af.foundationid=fid;-- ÓÐinto£¬ÕýÈ·±àÒë
  select af.keynode from APPFOUNDATION


Ïà¹ØÎĵµ£º

jdbcÁ¬½ÓOracle

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

oracle²»¿É¸üеÄÊÔͼ

¹Ø¼ü´Ê£ºwith read only
×÷ÓãºÓÃÓÚÖ¸¶¨Ëù´´½¨µÄÊÔͼ²»¿ÉÒÔͨ¹ý±¾ÊÓͼ¸üбí
Ö´ÐÐÒ»ÏÂSQL£¬´´½¨±íT£¬ºÍÁ½¸öÊÔͼV1£¬V2£º
CREATE TABLE T(ID INTEGER);
CREATE VIEW V1 AS SELECT * from T;
CREATE VIEW V2 AS SELECT * from T WITH READ ONLY;
Ö´ÐÐSQL:
INSERT INTO V1 VALUES(1);
--------------------
1 row cre ......

Oracle 10g ÖÐÎÄÂÒÂëÎÊÌâ

ÎÊÌ⣺Êý¾Ý¿âΪ£ºOracle Database 10g Release 2
¡¡¡¡²Ù×÷ϵͳΪ£ºWindows Vista/Windows XP MCE(Á½¸ö²Ù×÷ϵͳ·Ö±ð°²×°ºó³öÏÖÏàͬÎÊÌâ)
¡¡¡¡Êý¾Ý¿â°²×°ºó(һ·ĬÈÏÖµ)£¬³¢ÊÔInsertÊý¾ÝºóSelect³öÀ´£¬Ô­À´µÄÖÐÎÄ×Ö¶ÎÖµ±ä³ÉÁË??????ÐÎʽµÄÂÒÂ룬¸ÃÈçºÎ½â¾ö£¿
¡¡¡¡ÔÚÍøÉϲéÁËһЩ×ÊÁÏ£¬ËµÊÇ·þÎñÆ÷Óë¿Í»§¶Ë×Ö·û¼¯²»Æ¥Å䣬µ«Î ......

ÌáÈ¡Oracleµ±Ç°Óû§Ãû£¬»úÆ÷Ãû£¬IPµÄ·½·¨

select sysdate  µ±Ç°Ê±¼ä,
       sys.login_user  Êý¾Ý¿âÓû§,
       machine   µÇ¼»úÆ÷Ãû,
       SYS_CONTEXT('USERENV', 'IP_ADDRESS')   µÇ¼IP,
     &n ......

Oracle´æ´¢¹ý³Ì×ܽá(Ò»¡¢»ù±¾Ó¦ÓÃ)

1¡¢´´½¨´æ´¢¹ý³Ì
create or replace procedure test(var_name_1 in type,var_name_2 out type) as
--ÉùÃ÷±äÁ¿(±äÁ¿Ãû ±äÁ¿ÀàÐÍ)
begin
--´æ´¢¹ý³ÌµÄÖ´ÐÐÌå
end test;
´òÓ¡³öÊäÈëµÄʱ¼äÐÅÏ¢
E.g:
create or replace procedure test(workDate in Date) is
begin
dbms_output.putline('The input date is: ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ