Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Go Create PROC dbo.PROC_ADD_ADMISSION_RECORD(
@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:

Asked before and changed the proc name but the same error pops up.
Posted
Updated 12-Dec-21 23:08pm
Comments
Richard Deeming 13-Dec-21 4:28am    
REPOST
You have already posted this question:
Declare the scalar variable person_id[^]

If you want to update your question to add missing information, click the green "Improve question" link and update your question.

Do not post your update as a "new" question.
Richard MacCutchan 13-Dec-21 4:57am    
You really need to go and study the syntax of SQL rather than reposting these questions again and again.

1 solution

As this question is tagged "MySQL" then you should use the correct syntax for MySQL
MySQL :: MySQL 5.7 Reference Manual :: 13.1.16 CREATE PROCEDURE and CREATE FUNCTION Statements[^] For a start I don't think you can abbreviate the word PROCEDURE

The parameters must be defined as IN (or OUT) and should not have the @ symbol. This does mean that your parameters will have the exact names as your columns - you have already been told that is not good practice, so consider using something to distinguish one from the other.

Also - you are missing the closing ) on the parameter list and that AS should not be there

Also, are you sure you meant
SQL
@ADMIS_ID INT= NULL,
@PERSON_ID INT(4)= NULL,
@DOCTOR_ID INT(4) = NULL,
because AFAIK you can't give default values to MySQL parameters like that.

Also there is no such thing in MySQL as
SQL
SET NOCOUNT ON
So this procedure is largely written as MSSQL. If that is what you really want then lose the (4)on the parameter definitions
 
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