Question: Why am I getting this error when executing the stored procedure? (code attached). Here is the question: The relevant tables I previously created: 7. Create

Why am I getting this error when executing the stored procedure? (code attached).

Here is the question:

Why am I getting this error when executing the stored procedure? (code

attached). Here is the question: The relevant tables I previously created: 7.The relevant tables I previously created:

Create a reusable stored procedure named "add like" that uses parameters and

7. Create a reusable stored procedure named "add like" that uses parameters and allows you to insert any new "like". Rather than passing in the person id value as a parameter to identify which person is liking which post, pass in the username of the person. The stored procedure should then lookup the person id and store it in a variable to be used in the insert statement. Execute the procedure to add a "like" of your choosing, then list out the Like table to show the addition succeeded. 1 2. 3 4 CREATE OR ALTER PROCEDURE add_like @p_post_id DECIMAL (12), @p_username VARCHAR(20), @p_liked_on DATE AS BEGIN DECLARE @v_person_id DECIMAL (12); 5 6 7 8 9 10 SELECT @v_person_id = person_id FROM Person WHERE username = @p_username 11 12 13 14 15 16 17 18 INSERT INTO Likes (likes_id, person_id, post_id, liked_on) VALUES (NEXT VALUE FOR Likes_seq, @v_person_id, @p_post_id, @p_liked_on) END; GO EXECUTE add_like 'taylorswift', 18, '27-FEB-2020'; 100 % Messages Msg 8114, Level 16, State 5, Procedure add_like, Line O [Batch Start Line 16] Error converting data type varchar to decimal. Completion time: 2021-02-15T02:06:40.6247761-06:00 | CREATE TABLE Person person_id DECIMAL (12) NOT NULL, first_name VARCHAR(32) NOT NULL, last_name VARCHAR (32) NOT NULL, username VARCHAR (20) NOT NULL, PRIMARY KEY person_id)); CREATE TABLE Post post_id DECIMAL (12) NOT NULL, person_id DECIMAL (12) NOT NULL, content VARCHAR 255) NOT NULL, created_on DATE NOT NULL, summary VARCHAR (15) NOT NULL PRIMARY KEY (post_id), FOREIGN KEY (person_id) REFERENCES Person) CREATE TABLE Likes likes_id DECIMAL (12) NOT NULL, person_id DECIMAL (12) NOT NULL, post_id DECIMAL (12) NOT NULL, liked_on DATE, PRIMARY KEY (likes_id), FOREIGN KEY (person_id) REFERENCES Person, FOREIGN KEY (post_id) REFERENCES Post)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!