title: Error 1604 ..right syntax to use near '' at line
body: <p>I have created the following stored procedure and for the life of me I do not understand why I get the above error. I tried moving the END // slashes closer and further away, I added a ; before the //
  What am I doing wrong?</p>
  
  <pre><code>DELIMITER //
  CREATE PROCEDURE ETL10501(TableStartPointer TIMESTAMP, TableWindowPointer TIMESTAMP)
  BEGIN
      DECLARE RowsExtractedCnt INT;
      DECLARE RowsExtractedMaxID INT;
      DECLARE RowsInsertedMaxID INT;
      DECLARE InsertedRowCount INT;
      DECLARE tmpTableWindowPointer TIMESTAMP;
  
      SELECT RowsExtractedCnt = COUNT(*), RowsExtractedMaxID = MAX(ID) FROM tbl10501Raw 
          WHERE tbl10501Raw.DeviceReportedTime = tbl10501Raw.ReceivedAt 
          AND tbl10501Raw.DeviceReportedTime BETWEEN TableWindowPointer AND TableStartPointer;
  
      SELECT RowsInsertedMaxID = (SELECT MAX(RowsExtractedMaxID10501) FROM etlETLEventLog);
  
      IF RowsExtractedMaxID IS NULL THEN SET RowsExtractedMaxID:=0;
      IF RowsInsertedMaxID  IS NULL THEN SET RowsInsertedMaxID:=0;
  
      IF RowsExtractedMaxID &gt; RowsInsertedMaxID THEN
          SELECT tbl10501Raw.DeviceReportedTime INTO tmpTableWindowPointer FROM tbl10501Raw 
              WHERE RowsInsertedMaxID = (tbl10501Raw.ID + 1);
          INSERT INTO tblLast7Days
              (CustomerID, DeviceID, Message, Facility, Severity, DeviceReportedTime, 
              InfoUnitID, SysLogTag)  
          SELECT tbl10501Raw.CustomerID, etlDIMDeviceNumbers.DeviceID, tbl10501Raw.Message, 
              tbl10501Raw.Facility, tbl10501Raw.Severity, tbl10501Raw.DeviceReportedTime, 
              tbl10501Raw.InfoUnitID, tbl10501Raw.SyslogTag
          FROM etlDIMDeviceNumbers, tbl10501Raw
          WHERE tbl10501Raw.DeviceReportedTime = tbl10501Raw.ReceivedAt
          AND tbl10501Raw.FromHostIP = etlDIMDeviceNumbers.DeviceIPAddress
          AND tbl10501Raw.DeviceReportedTime BETWEEN tmpTableWindowPointer AND TableStartPointer;
  
          SELECT InsertedRowCount = COUNT(*) 
              FROM etlDIMDeviceNumbers, tbl10501Raw
              WHERE tbl10501Raw.DeviceReportedTime = tbl10501Raw.ReceivedAt
              AND tbl10501Raw.FromHostIP = etlDIMDeviceNumbers.DeviceIPAddress
              AND tbl10501Raw.DeviceReportedTime BETWEEN tmpTableWindowPointer AND 
              TableStartPointer;
  
          UPDATE etlETLEventLog 
              SET RowsActualInserted10501 = InsertedRowCount, 
                  RowsExtractedCnt10501 = RowsExtractedCnt, 
                  RowsExtractedMaxID10501 = RowsExtractedMaxID
          WHERE etlETLEventLog.TableStartPointer = TableStartPointer;
      END IF;
  END; // 
  DELIMITER ;
  </code></pre>
  
  <p>Thank you in advance.</p>