norainirahim norainirahim - 3 years ago 255
SQL Question

Sql ibm db2 (windows 10) not reading end if; (stored procedure)

I'm having this error for my stored procedure. My ibm db2 doesn't seem to be reading the END IF; statement.
I'm using Windows 10 for my db2.

ERROR MESSAGE:
SQL0104N An unexpected token "END@" was found following "_Details)". Expected
tokens may include: "
END IF".

CREATE PROCEDURE SeatPricing (IN seat_num varchar (2), ticket_id varchar
(10))
BEGIN
IF seat_num LIKE 'A_' THEN
UPDATE Ticket_Details
SET seat_price = 500.00
WHERE ticket_id = (SELECT ticket_id
FROM Ticket_Details);
UPDATE Ticket
SET seat_price = 500.00
WHERE ticket_id = (SELECT ticket_id
FROM Ticket);
ELSE
UPDATE Ticket_Details
SET seat_price = 300.00
WHERE ticket_id = (SELECT ticket_id
FROM Ticket_Details);
UPDATE Ticket
SET seat_price = 300.00
WHERE ticket_id = (SELECT ticket_id
FROM Ticket);
END IF;
END@
/

Answer Source

ERROR MESSAGE: SQL0104N An unexpected token "END@" was found following "_Details)". Expected tokens may include: " END IF".

Always refer the syntax for creating procedure. You need to end your procedure by ONLY END with optional <procedure-name>.

But, you have used END@ at the end, which should be either END or END SeatPricing.

END - A mandatory keyword that ends the block. You can optionally specify the name of the procedure.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download