¹ØÓÚÊý¾Ý²Ö¿âÖи´ÔÓ±¨±íSQLÓï¾äµÄд·¨
Ô´´ÓÚ2008Äê04ÔÂ02ÈÕ£¬2009Äê10ÔÂ18ÈÕǨÒÆÖÁ´Ë¡£
ÔÚÊý¾Ý²Ö¿âµÄ»ù±¾±¨±íÖÆ×÷¹ý³ÌÖУ¬Í¨³£»áʹÓÃ
SQL
×÷ΪÊý¾ÝÔ´£¬¿ÉÊÇÆÕͨµÄ
SQL
ʵ
ÔÚ²»Êʺϴ¦ÀíһЩ½ÏΪ¸´ÔÓµÄÂß¼Åжϣ»Ò»°ã¶øÑÔ£¬´ý²éѯµÄÊý¾ÝÀàÐÍÖ÷Òª°üÀ¨ÈÕÆÚÐÍ¡¢Êý×ÖÐÍ¡¢×Ö·û´®ÕâÈýÀàÊý¾ÝÀàÐÍ£»ÔÚ±¨±í²éѯ½çÃæÇ°¶Î£¬Êµ¼ÊÉÏ»á¶Ô²éѯµÄ
Êý¾Ý×÷һЩȱʡ´¦Àí£¬ÀýÈçÓÐЩ×ֶοÉÊä¿É²»Ê䣬ÊäÈëµÄ×Ö¶ÎÐèÒª°´ÕÕÊäÈëµÄÄÚÈݽøÐвéѯ£¬¶øδÊäÈëµÄ×Ö¶Îͨ³£»áÑ¡ÔñºöÂÔ¸ÃÌõ¼þµÄ´æÔÚ£¬ÈçºÎÅжϸÃ×Ö¶ÎÊÇ·ñÊä
ÈëÁËÄØ£¬µ±È»ÊÇÕë¶ÔÕâЩδÊäÈëµÄ×Ö¶ÎÌṩһЩȱʡֵÁË£¬ÀýÈçij¸öÊý×ÖÀàÐ͵Ä×Ö¶ÎδÊäÈ룬Ôò¸³Ò»¸öȱʡֵ
-1
£¬Ä³¸ö×Ö·û´®×Ö¶ÎδÊäÈ룬Ôò¸³Ò»¸öȱʡֵΪ
’ ‘
£¬Ä³¸öÈÕÆÚδÊäÈ룬Ôò¸³Ò»¸öȱʡֵΪ
SYSDATE
£»Õâ¸öʱºòÖ»ÒªÔÚ
SQL
ÖÐÕë¶Ô²»Í¬µÄȱʡֵºÍÓ¦¸ÃÊäÈëµÄÖµ½øÐд¦Àí¾Í
OK
ÁË¡£
µ±È»µ±¸ü¼Ó¸´ÔӵIJéѯÂ߼ʵÔÚ²»ÊʺÏÓÃ
SQL
´¦Àíʱ£¬×îºÃÑ¡ÔñʹÓô洢¹ý³ÌµÄ·½·¨ÁË£»Æä´Î¹ýÓÚ¸´ÔÓµÄ
SQL
¿ÉÄÜ»á´øÀ´Êý¾Ý¿â
ÐÔÄÜÎÊÌ⣬Òò´ËÕâЩ»ùÓÚ
SQL
µÄ±¨±í×îºÃ²»ÒªÔÚ´óÐÍÊý¾Ý±íÉϲÙ×÷¡£
ÏÂÃæÊǹ¹ÔìÁËÒ»¸ö°üº¬ÒÔÉÏÈýÖÖÊý¾ÝÀàÐ͵ÄÊý¾Ý±í£¬²¢Ìî³äÁËһЩ²âÊÔÊý¾Ý¡£
CREATE TABLE TestReportParameter
(
VarcharField VARCHAR2(20),
NumberField NUMBER(10,0),
DateField DATE
);
INSERT INTO TestReportParameter VALUES('a',1,SYSDATE-1);
INSERT INTO TestReportParameter VALUES('b',2,SYSDATE);
INSERT INTO TestReportParameter VALUES('c',3,SYSDATE+2);
INSERT INTO TestReportParameter VALUES('d',4,SYSDATE-2);
COMMIT;
´¦ÀíµÄÃØÃÜÔÚÓÚ¶ÔȱʡֵºÍÊäÈëÖµÖ®¼ä×öÒ»¸öÅжϣ¬±£³ÖÈκÎÒ»ÖÖÖµµÄ´æÔÚΪ
TRUE
¼´¿É¡£
¶ÔÓÚµ¥ÖµÊý¾ÝµÄ´¦Àí±È½Ï¼òµ¥£¬²Î¿´ÏÂÃæ½Å±¾
SELECT *
from TestReportParameter
WHERE (' ' = &VarcharField OR VarcharField = &VarcharField)
AND (-1 = &NumberField OR NumberField = &NumberField)
¶ÔÓÚ¶àÑ¡ÖµµÄ´¦ÀíÔòÒ»¶¨ÒªÊ¹ÓÃ
DECODE
º¯Êý²ÅÄܱÜÃâ´íÎóµÄ·¢Éú£¬´¦ÀíµÄÂ߼ͬÉÏ¡£
SELECT *
from TestReportParameter
WHERE (
' '=DECODE(&VarcharField,' ',' ',&
Ïà¹ØÎĵµ£º
Ò»¡¢SQL SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......
Ç°ÑÔ
InternetµÄ¹æģÿһ°ÙÌì¾Í»áÔö³¤Ò»±¶£¬¿Í»§Ï£Íû»ñµÃ7Ìì×24СʱµÄ²»¼ä¶Ï¿ÉÓÃÐÔ¼°½Ï¿ìµÄϵͳ·´Ó¦Ê±¼ä£¬¶ø²»Ô¸ÂŴο´µ½Ä³¸öÕ¾µã“Server Too Busy”¼°Æµ·±µÄϵͳ¹ÊÕÏ¡£
Ëæ×ÅÒµÎñÁ¿µÄÌá¸ß,ÒÔ¼°·ÃÎÊÁ¿ºÍÊý¾ÝÁ÷Á¿µÄ¿ìËÙÔö³¤£¬ÍøÂç¸÷¸öºËÐIJ¿·ÖµÄ´¦ÀíÐÔÄܺͼÆËãÇ¿¶ÈÒ²ÏàÓ¦Ôö´ó£¬Ê¹µÃµ¥Ò»É豸¸ù±¾ÎÞ·¨³Ðµ£¡£ ......
8. bulk collect /forall
ʹÓÃbulk collect¿ÉÒԳɿéµØ¶ÁÈ¡Êý¾Ý£¬Ëü¿ÉʹSQLÒýÇæÔÚ·µ»ØÊä³ö½á¹û¸øPL/SQLÒýÇæ֮ǰ´óÅú°ó¶¨Êä³ö¼¯ºÏ¡£ÕâÑù¿ÉÒÔÒ»´ÎÐԵذÑÊý¾Ý¶¯Ì¬µØ×°Ôص½¼¯ºÏÖУ¬µ«bulk collectÐèÒª´óÁ¿ÄÚ´æ¡£bulk collect¿ÉÓÃÓÚselect into¡¢fetch intoºÍreturning intoÓï¾äÖС£
¡ñ se ......