MySQL Forums
Forum List  »  Stored Procedures

Stored Procedure Error
Posted by: Matthew Dryden
Date: December 22, 2018 01:29PM

I'm trying to create the following stored procedure, but MySQL has an issue with the line "HAVING count(1) > 1;" The exact error is:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 12 0.000 sec

However the command works when its not part of a stored procedure, so I'm a bit stuck. Any help would be great, thanks!

CREATE PROCEDURE ETL_BILLS()
BEGIN

CREATE temporary table dupes
SELECT TRANS_DATE
, TRANS_DESC
, SUM( CASE WHEN DEBIT = '' THEN 0 ELSE cast( DEBIT as DECIMAL(18,2) ) END ) AS DEBIT
, SUM( CASE WHEN CREDIT = '' THEN 0 ELSE cast( CREDIT as DECIMAL(18,2) ) END ) AS CREDIT
FROM BILLS.BILLS_LOAD
GROUP BY TRANS_DATE
, TRANS_DESC
HAVING count(1) > 1;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
Stored Procedure Error
225
December 22, 2018 01:29PM
98
December 23, 2018 05:00PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.