Reputation: 67
CREATE VIEW nextClass AS
SELECT date,id
FROM class
WHERE date >= CURDATE()
AND IF (
date < CURDATE(),
ERROR_MESSAGE('You cannot update previous classs'),
CLOSE()
)
Can someone help with the CREATE VIEW statement in SQL. I need to show all future classes and reject attempts to update previous classes. I have a syntax error in this code.
Upvotes: 0
Views: 59
Reputation: 34232
Pls refer to mysql's documentation on creating views:
The WITH CHECK OPTION clause can be given for an updatable view to prevent inserts or updates to rows except those for which the WHERE clause in the select_statement is true.
So, all you need to do is to add WITH CHECK OPTION
to the end of the CREATE VIEW
statement.
Upvotes: 1