我需要有关SQL过程的帮助。我已经尝试并尽我所能,但以下程序不起作用,需要帮助,为什么它不起作用,
.navbarfooter {
display: inline-block;
}
.navbarfooter {
display: flex;
justify-content: center;
margin: 0 auto;
}
.navbarfooter-mainlink:nth-child(n+2):before {
content: "";
display: inline-block;
height: 10px;
width: 1px;
background-color: hsla(0,0%,4%,.3);
margin: 0 15px;
pointer-events: none;
}
.navbarfooter-mainlink {
white-space: nowrap;
}
.navbarfooter-mainlink {
font-size: 17px;
display: inline-block;
white-space: nowrap;
padding: 5px;
}
@media only screen and (max-width: 740px) {
.navbarfooter {
flex-wrap: wrap;
}
}
以上更新为学生查询并插入查询两者单独工作。但不是在插入CREATE PROCEDURE updateUser
(IN ID INT(11),
name VARCHAR(100),
email VARCHAR(100),
role VARCHAR(9),
gender VARCHAR(6),
birthday VARCHAR(10),
classroom INT(11) )
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
IF EXISTS (SELECT * FROM student WHERE userID = ID)
BEGIN
UPDATE tbl_users
SET userName = name, userEmail = email, userRole = role,
gender = gender, birthday = birthday
WHERE userID = ID;
UPDATE student
SET classID = classroom
WHERE userID = ID;
END
ELSE
BEGIN
UPDATE tbl_users
SET userName = name, userEmail = email, userRole = role,
gender = gender, birthday = birthday
WHERE userID = ID;
INSERT INTO student(classID, userID)
VALUES (classroom, ID);
END
COMMIT TRANSACTION;
时。
答案 0 :(得分:0)
因为您使用的是MySQL。请尝试以下代码,看看它是否有效,
CREATE PROCEDURE updateUser
(IN ID INT(11),
name VARCHAR(100),
email VARCHAR(100),
role VARCHAR(9),
gender VARCHAR(6),
birthday VARCHAR(10),
classroom INT(11) )
BEGIN
IF EXISTS (SELECT * FROM student WHERE userID = ID) THEN
START TRANSACTION;
UPDATE tbl_users
SET userName = name, userEmail = email, userRole = role,
gender = gender, birthday = birthday
WHERE userID = ID;
UPDATE student
SET classID = classroom
WHERE userID = ID;
COMMIT;
ELSE
START TRANSACTION;
UPDATE tbl_users
SET userName = name, userEmail = email, userRole = role,
gender = gender, birthday = birthday
WHERE userID = ID;
INSERT INTO student(classID, userID)
VALUES (classroom, ID);
COMMIT;
END IF;
END;