ÄÚÁª SQL PL(Inline SQL PL)
----start
ͨ³£SQL PLÖ»ÄÜʹÓÃÔÚ´æ´¢¹ý³Ì¡¢´¥·¢Æ÷¡¢Óû§×Ô¶¨Ò庯ÊýÖУ¬µ«ÊÇÓÐÒ»²¿·ÖSQL PLÒ²¿ÉÒÔÖ±½ÓÔÚÃüÁîÐÐ±à¼Æ÷»ò½Å±¾ÖÐʹÓã¬ËüÃÇÊÇ£º
DECLARE <variable>
SET
CASE
FOR
GET DIAGNOSTICS
GOTO
IF
RETURN
SIGNAL
WHILE
ITERATE
LEAVE
ÒÔÏÂSQL PL²»ÄÜÖ±½ÓÔÚÃüÁîÐÐ±à¼Æ÷»ò½Å±¾ÖÐʹÓã¬ËüÃÇÖ»ÄÜÔÚ´æ´¢¹ý³Ì¡¢´¥·¢Æ÷¡¢Óû§×Ô¶¨Ò庯ÊýÖÐʹÓãº
ALLOCATE CURSOR
ASSOCIATE LOCATORS
DECLARE <cursor>
DECLARE ...HANDLER
PREPARE
EXECUTE
EXECUTE IMMEDIATE
LOOP
REPEAT
RESIGNAL
CALL
COMMIT/ROLLBACK
ʾÀý£º
--Á¬½ÓÊý¾Ý¿â
CONNECT TO SAMPLE!
--ÄÚÁªSQL PL
BEGIN
DECLARE I INT DEFAULT 1;
DECLARE NUM INT DEFAULT 0;
SET NUM=0;
WHILE I<=10
DO
SET NUM=NUM+I;
SET I=I+1;
END WHILE;
END!
--¹Ø±ÕÁ¬½Ó
CONNECT RESET!
µ÷ÓÃʾÀý£º
½«Ê¾ÀýµÄÄÚÈݱ£´æÎªc:\test.sql,È»ºóÔÚDB2 ÃüÁî´°¿ÚÖÐÖ´ÐÐÈçÏÂÃüÁî
db2 -td! -vf c:\test.sql
----¸ü¶à²Î¼û£ºSQL PL ¼ò½é
----ÉùÃ÷£º×ªÔØÇë×¢Ã÷³ö´¦¡£
----last updated 2010.2.9
----written by wave at 2010.2.9
----end
Ïà¹ØÎĵµ£º
DB2 SQL PL
SQL PLÊÇDB2ËùÖ§³ÖµÄ¹ý³Ì»¯ÓïÑÔ£¬ËüÊÇSQL/PSM±ê×¼µÄÒ»¸ö×Ó¼¯¡£Æä¸ù¾ÝÓ¦Ó÷¶Î§²»Í¬£¬ÓÖ·ÖΪInline SQL PL£¬Embeded SQL PLºÍCompiled SQL PL¡£
Inline SQL PL
ÊÊÓ÷¶Î§£º´¥·¢Æ÷¡¢º¯ÊýºÍ·½·¨£¬Ö§³Ö²¿·ÖSQL PL£¬Ê¹ÓÃʱҪעÒâһЩÏÞÖÆ
Óï·¨¹æÔò£ºBEGIN ATOMIC ... END
Embeded SQL PL
ÊÊÓ÷¶Î§£ºÇ¶Èëʽ£¬Åäº ......
ÔÚiBatis 2.xÖУ¬¿ÉÒÔʹÓÃ$xxxx$Óï·¨ÔÚSQLÖж¨Òå¿É¶¯Ì¬²åÈëµÄSQLÔªËØ¡£¶øÔÚiBatis 3.xÖÐÒѾ·¢ÉúÁ˺ܴó±ä»¯¡£
Ê×ÏÈ£¬Óï·¨±äΪ ${xxxx} ÐÎʽ£»
Æäʵ£¬ÄãҪʹÓõÄSQLÔªËØ±ØÐëÊÇÒ»¸öJava BeanµÄÊôÐÔ£¬Ò²ËµÊÇÊäÈë²ÎÊý±ØÐëΪJava Bean£»ÔÚ˵Ã÷ÎĵµÖÐҲûÓÐ˵Ã÷ÈçºÎÖ±½ÓʹÓÃÒ»¸öStringÀàÐ͵ÄÊäÈë²ÎÊý¡£
ÓÚÊÇ£¬ÎÒÓÃDEBUG·ÖÎöÁËi ......
Last login: Mon Feb 8 14:13:19 2010 from 192.168.1.249
ipnet
-bash-3.00$
-bash-3.00$ ipnet
-bash: ipnet: command not found
-bash-3.00$ su - oracle
Password:
eastcsu: incorrect password
-bash-3.00$ eastcom
-bash: eastcom: command not found
-bash-3.00$ su - oracle
Password:
[oracl ......
Ö÷¼ü:
Äܹ»Î¨Ò»±íʾÊý¾Ý±íÖеÄÿ¸ö¼Ç¼µÄ¡¾×ֶΡ¿»òÕß¡¾×ֶΡ¿µÄ×éºÏ¾Í³ÆÎªÖ÷Âë(Ö÷¼ü)¡£ Ò»¸öÖ÷¼üÊÇΨһʶ±ðÒ»¸ö±íµÄÿһ¼Ç¼£¬µ«ÕâÖ»ÊÇÆä×÷ÓõÄÒ»²¿·Ö£¬Ö÷¼üµÄÖ÷Òª×÷ÓÃÊǽ«¼Ç¼ºÍ´æ·ÅÔÚÆäËû±íÖеÄÊý¾Ý½øÐйØÁª¡£ÔÚÕâÒ»µãÉÏ£¬Ö÷¼üÊDz»Í¬±íÖи÷¼Ç¼֮¼äµÄ¼òµ¥Ö¸Õë¡£Ö÷¼üÔ¼Êø¾ÍÊÇÈ·¶¨±íÖеÄÿһÌõ¼Ç¼¡£Ö÷¼ü²»ÄÜÊÇ¿ÕÖµ¡£Î¨Ò ......