错误代码:1109未知表'消费者'在字段列表中

时间:2016-09-22 23:17:14

标签: mysql

我希望制作一个通过商店程序操作的表格。 我有2个程序可以选择和更新。第一个完美地执行,但最后一个有问题。它肯定感觉像mysql解析器问题。我希望我能在这里找到一些帮助,因为项目即将推出。运行第二个sp后,无论是通过SP还是基本查询,每个后续更新语句都会失败,直到我删除该记录为止;然后我可以再次插入然后通过基本查询调用更新。我需要使用SP,因为我正在与运行NodeJS的Web服务器进行通信。我正在使用node-mysql包。我使用的是mysql-5.7。

SECOND SP ERROR:错误代码:1109未知表'消费者'在字段列表中

谢谢, timecatcher

TABLE SCHEMA

    CREATE TABLE IF NOT EXISTS CONSUMER (
        signUpVerified BIT(1),
        signUpTimeStamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        loggedIn BIT(1),
        loginTimeStamp TIMESTAMP NOT NULL,
        consumerName VARCHAR(100),
        consumerEmail VARCHAR(254) UNIQUE NOT NULL,
        consumerPassword VARCHAR(20) NOT NULL,
        consumerAddress VARCHAR(100),
        consumerMapLocation VARCHAR(50),
        consumerMobileNumber VARCHAR(20) UNIQUE NOT NULL,
        consumerBalance FLOAT,
        lastSessionID BINARY(32),
        consumerID INT(30) UNIQUE AUTO_INCREMENT NOT NULL,
        PRIMARY KEY(consumerID)
    );

FIRST SP

    CREATE DEFINER=`root`@`%` PROCEDURE `CONSUMER_SIGN_UP_VERIFICATION`(IN lastSessionID BINARY(32), IN consumerEmail VARCHAR(254))
    BEGIN 
        IF ((consumerEmail IS NULL) OR (lastSessionID IS NULL)) THEN
            SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "EMAIL ADDRESS & SESSION ID REQUIRED";
        END IF;
        IF (EXISTS(SELECT * FROM CONSUMER WHERE (CONSUMER.consumerEmail = consumerEmail) AND (CONSUMER.signUpVerified = b'0'))) THEN
            IF ((SELECT CONSUMER.signUpTimeStamp FROM CONSUMER WHERE CONSUMER.consumerEmail = consumerEmail) = CHECK_SESSION_ID(lastSessionID, CONCAT("SANTEX", consumerEmail))) THEN
                UPDATE CONSUMER SET CONSUMER.signUpVerified = b'1' WHERE CONSUMER.consumerEmail = consumerEmail;
            ELSE
                DELETE FROM CONSUMER WHERE CONSUMER.consumerEmail = consumerEmail;
                SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "THIS SIGN UP VERIFICATION EMAIL SETUP HAS BEEN TAMPERED WITH, SO PLEASE START A NEW ACCOUNT";
            END IF;
        ELSE 
            SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "THIS ACCOUNT IS ALREADY REGISTERED OR THERE IS NO ACCOUNT REGISTERED WITH THIS EMAIL ADDRESS";
        END IF;
    END

SECOND SP

    CREATE DEFINER=`root`@`%` PROCEDURE `CONSUMER_LOGIN`(IN consumerEmail VARCHAR(254), IN consumerPassword VARCHAR(20), OUT lastSessionID BINARY(32))
    BEGIN
        IF (EXISTS(SELECT * FROM CONSUMER WHERE (CONSUMER.consumerEmail = consumerEmail) AND (CONSUMER.signUpVerified = b'1'))) THEN
            IF (EXISTS(SELECT * FROM CONSUMER WHERE (CONSUMER.consumerEmail = consumerEmail) AND (CONSUMER.consumerPassword = consumerPassword))) THEN
                SELECT @consumerID := CONSUMER.consumerID FROM CONSUMER NATURAL JOIN CONSUMER_SESSION WHERE (CONSUMER.consumerEmail = consumerEmail) AND (CONSUMER.consumerPassword = consumerPassword) AND ((CONSUMER.loggedIn = b'1') OR ((CONSUMER_SESSION.loginTimeStamp != CONSUMER_SESSION.logoutTimeStamp) AND (CONSUMER_SESSION.logoutTimeStamp IS NULL)));
                IF (@consumerID IS NULL) THEN
                    SET @loginTimeStamp := NOW();
                    SET lastSessionID = CREATE_SESSION_ID(@loginTimeStamp, CONCAT("SANTEX", consumerEmail));
                    UPDATE CONSUMER SET CONSUMER.loggedIn = b'1', CONSUMER.lastSessionID = lastSessionID WHERE (CONSUMER.consumerEmail = consumerEmail) AND (CONSUMER.consumerPassword = consumerPassword);
                    INSERT INTO CONSUMER_SESSION(CONSUMER_SESSION.consumerID, CONSUMER_SESSION.loginTimeStamp, CONSUMER_SESSION.sessionID, CONSUMER_SESSION.logoutTimeStamp) VALUES(@consumerID, @loginTimeStamp, lastSessionID, NULL);
                ELSE 
                    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "THIS ACCOUNT HAS NOT LOGGED OUT FROM ITS PREVIOUS SESSION OR REQUESTED A PASSWORD RESET. PLEASE TRY AGAIN LATER";
                END IF;
            ELSE 
                SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "INCORRECT EMAIL ADDRESS OR PASSWORD";
            END IF;
        ELSE 
            SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "THERE IS NO ACCOUNT REGISTERED WITH THIS EMAIL ADDRESS OR SIGN UP VERIFICATION PENDING";
        END IF;
    END

1 个答案:

答案 0 :(得分:0)

我很抱歉。我的触发器文件是1500行代码。我通过调用CONSUMER.loggedIn在触发器中犯了一个错误。谢谢你的时间