0
我寫了一個存儲過程,在我的本地機器上工作,但在服務器中,它不會執行!這將是有很大的幫助存儲過程在本地工作,但不會在服務器上執行
存儲過程是
DROP PROCEDURE `ASKUS_INSERT`// CREATE DEFINER=`root`@`localhost` PROCEDURE `ASKUS_INSERT`( SENDERCONSUMERID INT(11), QUESTION_POSTED TEXT, DESCRIPTION_POSTED TEXT, NETWORK_ID INT(11), COMMTYPEID INT(11), CONSUMERID INT(11), CATEGORY_ID INT(11), ACTIONID INT(11), QUESTION_SLUG TEXT ) BEGIN DECLARE LASTINSERTEDID INT DEFAULT 0; DECLARE GETTIPSAMOUNT INT DEFAULT 0; DECLARE GETTIPSAMOUNTCONSUMER INT DEFAULT 0; DECLARE SETTIPSAMOUNTCONSUMER INT DEFAULT 0; DECLARE CHECKCOUNTTIPSEXIST INT DEFAULT 0; SELECT COUNT(*) INTO CHECKCOUNTTIPSEXIST FROM ACTION_ENTERPRISE_MAPPING WHERE ACTION_ID = ACTIONID; IF CHECKCOUNTTIPSEXIST > 0 THEN SELECT SUM(TIP_AMOUNT) INTO GETTIPSAMOUNT FROM ACTION_ENTERPRISE_MAPPING WHERE ACTION_ID = ACTIONID; ELSE SET GETTIPSAMOUNT = 0; END IF; SELECT CONSUMER_TIPS INTO GETTIPSAMOUNTCONSUMER FROM CONSUMER_PROFILE WHERE CONSUMER_ID = SENDERCONSUMERID; SET SETTIPSAMOUNTCONSUMER = GETTIPSAMOUNTCONSUMER + GETTIPSAMOUNT; INSERT INTO NETWORK_COMMUNICATIONS (COMMUNICATIONS_ID,SENDER_CONSUMER_ID,NETWORK_COMM_TYPE_ID,PARENT_COMMUNICATIONS_ID,IS_ACTIVE,LAST_MOD_TIME,CONSUMER_ID) VALUES ('',SENDERCONSUMERID,COMMTYPEID,'0','1',NOW(),CONSUMERID); SET LASTINSERTEDID = LAST_INSERT_ID(); UPDATE CONSUMER_PROFILE SET CONSUMER_TIPS = SETTIPSAMOUNTCONSUMER WHERE CONSUMER_ID = SENDERCONSUMERID; INSERT INTO CONSUMER_ACTION_LOG (ACTION_LOG_ID,ACTION_ID,CONSUMER_ID,TIPS_AMOUNT,LAST_MOD_TIME,COMMUNICATIONS_ID,COMM_TYPE_ID) VALUES ('',ACTIONID,SENDERCONSUMERID,GETTIPSAMOUNT,NOW(),LASTINSERTEDID,ACTIONID); INSERT INTO NETWORK_COMMUNICATIONS_MESSAGE (NETWORK_COMMUNICATION_MESSAGE_ID,COMMUNICATIONS_ID,SUBJECT,MESSAGE,IS_ACTIVE,LAST_MOD_TIME,QUESTION_SLUG) VALUES ('',LASTINSERTEDID,QUESTION_POSTED,DESCRIPTION_POSTED,'1',NOW(),QUESTION_SLUG); INSERT INTO COMMUNICATION_INTEREST_MAPPING (ID,CONSUMER_INTEREST_EXPERT_ID,CONSUMER_ID,COMMUNICATION_ID,IN_NETWORK,LAST_MOD_TIME) VALUES ('',CATEGORY_ID,SENDERCONSUMERID,LASTINSERTEDID,NETWORK_ID,NOW()); IF SENDERCONSUMERID != 0 AND CONSUMERID != 0 AND SENDERCONSUMERID != CONSUMERID THEN INSERT INTO CONSUMER_NOTIFICATION (CONSUMER_NOTIFICATION_ID,CONSUMER_ID,SENDER_CONSUMER_ID,ACTION_ID,COMMUNICATIONS_ID,IS_ACTIVE,LAST_MOD_TIME) VALUES ('',CONSUMERID,SENDERCONSUMERID,COMMTYPEID,LASTINSERTEDID,'1',NOW()); END IF; END
它說有很多語法錯誤,也未知變量。在這種情況下,它不應該在我的本地主機上工作。但它確實!我很困惑!
所以我應該儘量把所有的「;」 ? – batty
不,請查看本手冊頁面:http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html:您可以將分隔符設置爲其他內容,然後添加您的過程,然後設置它背部。 – Nanne