Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The code below keeps getting an error;

Go
Create PROC debo.PERSON_ID(
@ADMIS_ID INT= NULL,
@PERSON_ID INT(4)= NULL,
@DOCTOR_ID INT(4) = NULL,
@ADMIS_DATE DATE NOT NULL,
@DISCH_DATE DATE NOT NULL
AS
BEGIN
SET NOCOUNT ON

INSERT INTO HOSP_ADMIS ( ADMIS_ID, PERSON_ID, DOCTOR_ID, ADMIS_DATE,DISCH_DATE)

VALUES ( @ADMIS_ID, @PERSON_ID, @DOCTOR_ID,@ADMIS_DATE,
@DISCH_DATE);

END
GO

What I have tried:

Honestly, I’m trying different syntax but still clueless on how to fix the error. New to MySQL so it’s understandable but I’m stuck
Posted
Updated 11-Dec-21 23:40pm
Comments
Richard MacCutchan 12-Dec-21 7:18am    
"The code below keeps getting an error;"
Suggestion 1: if you get an error then please show the exact error message and which line causes it.
Suggestion 2: make use of the documentation that is available at MySQL :: MySQL Documentation[^].

1 solution

I'd start by changing names: you have three items with the same name "Person_id":

1) The stored procedure is called PERSON_ID
2) The parameter is called @PERSON_ID
3) The column is called PERSON_ID

Not only does that make life confusing for developers reading your code, it's confusing for the system as well. You could get round it by fully qualifying the column name, but using "PERSON_ID" for a procedure isn't particularly helpful (it gives no clue as to what the procedure does) so a better solution would be to change that. Perhaps calling it AddAdmissionRecord would both cure the problem and make it more useful?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900