ORACLE PL/SQL¿ª·¢
¸Õ¸ÕÔÚinthirtiesÀÏ´óµÄ²©¿ÍÀï¿´µ½ÕâƪÎÄÕ£¬Ð´µÄ²»´í£¬ÕýºÃ×Ô¼º×î½üÔÚѧϰPL/SQL£¬×ª¹ýÀ´Ñ§Ï°Ñ§Ï°¡£
==================================================================================
bulk collectÊÇ¿ÉÒÔ¿´×öÊÇÒ»ÖÖÅú»ñÈ¡µÄ·½Ê½£¬ÔÚÎÒÃǵÄplsqlµÄ´úÂë¶ÎÀï¾³£×÷ΪintoµÄÀ©Õ¹À´Ê¹Ó᣶ÔÓÚselect id into v from .... ÊÇÒ»¸ö³£ÓõÄÓ÷¨¡£²»¹ýÕâÀïÖ»ÄÜÊÇ·µ»Øµ¥Ìõ¼Ç¼µÄʱºò£¬²ÅÄÜʹÓã¬Èç¹ûÊÇÓжàÌõ¼Ç¼ÎÒÃǾͲ»ÄÜÓÃÕâÑùµÄ·½Ê½£¬¶øÊÇʹÓÃfetchºÍÑ»·µÄ·½Ê½£¬²»½öʹÓÃÂé·³£¬¶øÇÒÐÔÄÜÒ²µ×Ï£¬ÕâʱÎÒÃǵÄbulk collect¡Öصdz¡ÁË£¬½â¾öÎÒÃǵÄÎÊÌâ¡£
ͨ¹ýbulk collect¿ÉÒÔ°ÑÎÒÃǵIJéѯ½á¹ûÒ»´ÎÐԵؼÓÔص½ÎÒÃǵÄǶÈë±íÖС£ÕâÑùÎÒÃDz»ÐèÒªºÜÂé·³µÄÓÃÓαêµÄÑ»·Ò»ÌõÒ»ÌõµÄÈ¥fetchß·£¬¿ÉÏë¶øÖª£¬ÕâÑù²»½ö²Ù×÷·½±ã£¬Ò²¿ÉÒÔ»ñµÃÏ൱²»´íµÄ³ÌÐòÐÔÄÜ¡£ ÎÒÃÇ¿ÉÒÔÔÚselect into, fetch into, returning intoµÄ¾ä×ÓÖÐʹÓá£ÏÂÃæÎÒÃÇͨ¹ý¶ÔÒÔÉϸ÷¸öÀý×ÓÀ´½øÐÐÑÝʾÀ´¿´¿´ËûÃǵÄÓ÷¨
ÏÈÀ´¿´¿´ÎÒÃǵIJâÊÔ±íºÍÊý¾Ý
SQL> desc test;
Name Null? Type
----------------------------------------- -------- ----------------------------
ZC_CODE VARCHAR2(20)
MONEY NUMBER(35)
MONEY_2 NUMBER(35)
SQL> col zc_code format a20;
SQL> col money format 999999.99;
SQL> col money_2 format 9999.99;
SQL>select * from test;
ZC_CODE MONEY MONEY_2
-------------------- ---------- --------
201 18600.00
20101 9600.00
2010101 3300.00
2010102 3200.00
2010103 3100.00
20102 9000.00
2010201 2000.00
2010202 7000.00
8 rows selected.
¶¨ÒåÎÒÃǵÄǶÌ×±íµÄÀàÐÍ£¬ ¶¨ÒåÔÚÒ»¸öpackageÀÕâ¸öpackageʹÎÒÃǵÄÊý¾ÝÀàÐͼ¯ºÏ
SQL> create or replace package ALL_DATA_TYPE is
2 type T_TESTROW is table of test1.test%rowtype index by binary_integer;
3 type T_TESTZCCODE is table of test1.test.zc_code%type index by binary_integer;
4 end;
5 /
ÏÈÀ´¸öselect intoµÄÀý×Ó
SQL> create or replace function test_bulkcollect return ALL_DATA_TYPE.T_TESTROW is
2 v_rtn ALL_DATA_TYPE.T_TESTROW;
3 begin
4 select * bulk collect into v_rtn from test;
5 return v_rtn;
6 end;
7 /
ͳһµÄ²âÊÔ·½·¨£¬ ÎÒÃÇ·Ö±ðÓÃÕâ¸ö²âÊÔ´úÂëÀ´ÑÝʾÒÔÉÏselect into£¬fetch in
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
Èý¡¢Ç¶Ì×±íµÄʹÓ÷½·¨
1¡¢½«Ç¶Ì×±í¶¨ÒåΪPL/SQLµÄ³ÌÐò¹¹Ôì¿é
TYPE type_name IS TABLE OF element_type[NOT NULL];
ÈçÏÂÀýËùʾ£º
DECLARE
-- Define a nested table of variable length strings.
TYPE card_table IS TABLE OF VARCHAR2(5 CHAR);
-- Declare and initialize a n ......
ÈÃÎÒÃÇ´ÓÕâÑùÒ»¸öʾÀý¿ªÊ¼ËµÆð£¬ËüÔÚ SQL Server 2000 ºÍ 2005 Öж¼ÄÜÒýÆðËÀËø¡£ÔÚ±¾ÎÄÖУ¬ÎÒʹÓà SQL Server 2005 µÄ×îРCTP£¨ÉçÇø¼¼ÊõÔ¤ÀÀ£¬Community Technology Preview£©°æ±¾£¬SQL Server 2005 Beta 2£¨7 Ô·¢²¼£©Ò²Í¬ÑùÊÊÓá£Èç¹ûÄúûÓÐ Beta 2 »ò×îÐ嵀 CTP °æ±¾£¬ÇëÏÂÔØ SQL Serve ......
ʲôÊÇÊý¾Ý¿â·ÖÇø£¿
Êý¾Ý¿â·ÖÇøÊÇÒ»ÖÖ¶Ô±íµÄºáÏò·Ö¸î£¬Sql server 2005ÆóÒµ°æºÍÖ®ºóµÄSql server°æ±¾²ÅÌṩÕâÖÖ¼¼Êõ£¬ÕâÖÖ¶Ô±íµÄºáÏò·Ö¸î²»Í¬ÓÚ2000Öеıí·Ö¸î£¬Ëü¶Ô·ÃÎÊÓû§ÊÇ͸Ã÷µÄ£¬Óû§²¢²»»á¸Ð¾õµÄ±í±»ºáÏò·Ö¸îÁË¡££¨2000ÖеıíºáÏò·Ö¸îÊǽ¨n¸ö±íÀýÈ簴ʱ¼ä½¨±íÿÔÂÒ»¸ö±í£¬±íÃû²»Í¬£¬×îºóÐèÒª×öÒ»¸ö´óÊÓͼ£©
¹ØÓÚ¾ß ......
ORACLE SQLÓï¾äÓÅ»¯×ܽá
1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, Ä ......