Question: MySQL - database stored procudure -- it is giving me error: Error Code: 1364. Field 'cno' doesn't have a default value How do I fix
MySQL - database stored procudure -- it is giving me error: Error Code: 1364. Field 'cno' doesn't have a default value
How do I fix it?
Create and exercise a SQL stored procedure called NewChirp(...) that the application can use to add a newly created (non-parroted) chirp to the database. The stored procedure should automatically use the current date and time to set those fields of the new chirp, and it should automatically generate the new chirps number by adding one to the chirpers previous highest chirp number.
DELIMITER $$
CREATE PROCEDURE NewChirp( new_btag VARCHAR(30), loc_lat DECIMAL(10,6), loc_long DECIMAL(10,6), sentiment DECIMAL(2,1), content VARCHAR(255)) BEGIN DECLARE new_cno INT(11); SET new_cno = ( SELECT MAX(cno) from Chirp) + 1; INSERT INTO Chirp (btag, location_latitude, location_longitude, sentiment, text) VALUES (new_btag, loc_lat, loc_long, sentiment, content); END;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
