sqlÖÐcallÊÇʲôÒâ˼
sql ÖÐµÄ call Óï¾äÓÃÓÚŲÓô洢Àú³Ì»òº¯Êý¡£´æ´¢Àú³ÌÊÇÒ»×éÔ¤±àÒëµÄ sql Óï¾ä£¬Í¨³£ÓÃÓÚÖ´ÐÐÖØ´óµÄÊý¾Ý¿â²Ù×÷¡£call Óï¾äµÄÓ﷨Ϊ£ºcall ([²ÎÊýÁбí])¡£²ÎÊýÁбí¿ÉÒÔ°üÀ¨ÊäÈë²ÎÊý£¨in£©¡¢Êä³ö²ÎÊý£¨out£©»òÊäÈë/Êä³ö²ÎÊý£¨inout£©¡£
SQL ÖÐµÄ CALL Óï¾ä
CALL Óï¾äÊÇʲô£¿
CALL Óï¾äÓÃÓÚÔÚ SQL ÖÐŲÓô洢Àú³Ì»òº¯Êý¡£´æ´¢Àú³ÌÊÇÒ»×éÔ¤±àÒëµÄ SQL Óï¾ä£¬Í¨³£ÓÃÓÚÖ´ÐÐÖØ´óµÄÊý¾Ý¿â²Ù×÷¡£
CALL Óï¾äµÄÓï·¨
CALL ([²ÎÊýÁбí]);
µÇ¼ºó¸´ÖÆ
²ÎÊýÁбí
´æ´¢Àú³Ì»òº¯Êý¿ÉÒÔ½ÓÊܲÎÊý¡£ÕâЩ²ÎÊýÔÚ CALL Óï¾äÖÐ×÷Ϊ¶ººÅÍÑÀëµÄÁбíÌṩ¡£²ÎÊý¿ÉÒÔÊÇ£º
ÊäÈë²ÎÊý£¨IN£©£º×ª´ï¸ø´æ´¢Àú³Ì»òº¯ÊýµÄÊý¾Ý¡£
Êä³ö²ÎÊý£¨OUT£©£ºÔÚÖ´Ðд洢Àú³Ì»òº¯Êýºó·µ»ØÊý¾Ý¡£
ÊäÈë/Êä³ö²ÎÊý£¨INOUT£©£º¼Èת´ïÊý¾Ý¸ø´æ´¢Àú³Ì»òº¯Êý£¬ÓÖ·µ»ØÊý¾Ý¡£
ʾÀý
ŲÓô洢Àú³Ì£º
CALL GetEmployeeInfo(12345);
µÇ¼ºó¸´ÖÆ
Õâ¸ö CALL Óï¾äŲÓô洢Àú³Ì GetEmployeeInfo£¬²¢ÏòÆäת´ïÔ±¹¤ ID 12345 ×÷ΪÊäÈë²ÎÊý¡£
ŲÓú¯Êý£º
SELECT CalculateTotal(@total);
µÇ¼ºó¸´ÖÆ
Õâ¸ö CALL Óï¾äŲÓú¯Êý CalculateTotal¡£@total ÊÇÒ»¸öÊä³ö²ÎÊý£¬ÔÚÖ´Ðк¯Êýºó½«°üÀ¨ÅÌËã³öµÄ×ܺ͡£
ÒÔÉϾÍÊÇsqlÖÐcallÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡