Question :
I facing the issue in executing a SQL Stored Procedure and I got the error message as showing syntax error in my statement, but I couldn’t find that,
Stored Procedure
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
DELIMITER $$
CREATE PROCEDURE enterprisedb
.orderstatus
(
IN inmode varchar(27),
IN OrderStatus_id int,
IN Status_comments varchar(255),
IN CreatedOn datetime,
IN CreatedBy varchar(255),
IN UpdatedOn datetime,
IN UpdatedBy varchar(255),
IN is_active bit
)
BEGIN
/*insert*/
if inmode = 'insert'
then
insert into orderstatus
(OrderStatus_id, OrderStatus, Status_comments, CreatedOn, CreatedBy, UpdatedOn, UpdatedBy, is_active)
values
(OrderStatus_id, OrderStatus, Status_comments, CreatedOn, CreatedBy, UpdatedOn, UpdatedBy, is_active);
end if;
/*update*/
if inmode = 'update'
then
update orderstatus ods
set
ods.OrderStatus = OrderStatus,
ods.Status_comments = Status_comments,
ods.CreatedOn = CreatedOn,
ods.CreatedBy = CreatedBy,
ods.UpdatedOn = UpdatedOn,
ods.UpdatedBy = UpdatedBy,
ods.is_active = is_active
where
ods.OrderStatus_id = OrderStatus_id;
/*delete*/
if inmode = 'delete'
then
update orderstatus ods
set
ods.is_active = 0
where
ods.OrderStatu_id = OrderStatus_id;
end if;
/*select*/
if inmode = 'select'
then
select * from orderstatus ods
where
ods.OrderStatus_id = OrderStatus_id;
end if; END
It displays the following messages,I couldn’t find the error.
- Can I click on the Yes button and continue with procedure?
- Will it cause any issue?
- How to solve this? a
A
Any suggestions, answers and comments are welcome.
Thanks in advance.
Answer :
Are you perhaps missing an “end if;” from the “if inmode = ‘delete'” statement?