Domanda

I am converting stored procs from MSSQL to MYSQL and am stuck at a certain point . I am receiving an error on DEALLOCATE Duration_Cursor error is UNEXPECTED IDENT_QUOTED expecting PREPARE_SYM . If i remove the line DEALLOCATE CURSOR i receive error on END WHILE saying unexpected WHILE expecting IF. I know it is a trivial mistake but i do not seem to get it below is the code :

FETCH NEXT FROM Duration_Cursor INTO m_Duration   ; 

 IF  (@@FETCH_STATUS = 0  )       
  THEN          

 WHILE (@InnerFlag=1)          
   DO          
     SET m_MIN = m_Duration / 30;          
     SET m_SEC = m_Duration % 30;          

    IF (m_MIN=0 )       
      THEN        
       SET m_MIN=1;       
       SET m_SEC=0;       


   ELSE if (m_SEC >= 15)           
     THEN          
      set m_MIN=m_MIN+1 ;         
      SET m_SEC=0 ;                 

   ELSE if (m_SEC < 15 AND m_SEC > 0) 
    THEN         
      SET m_SEC=50 ;-- 45                     

   END IF;        



     SET m_CommuSum_MIN_US = m_CommuSum_MIN_US + cast( CONCAT(CAST( m_MIN as  char(5)),'.', CAST( m_SEC as char(5))) as decimal);          


    FETCH NEXT FROM Duration_Cursor INTO m_Duration ;         


   IF (@@FETCH_STATUS <> 0)          
              THEN          

    SET InnerFlag = 0 ;    
            DEALLOCATE Duration_Cursor;         
      END IF;

      END WHILE;


  END IF ;

Can someone help please

È stato utile?

Soluzione

In MySQL, the DEALLOCATE is used to drop a prepared statement but not cursor.

DEALLOCATE PREPARE Syntax

{DEALLOCATE | DROP} PREPARE stmt_name

And on cursor, you might be trying to close it.

Cursor CLOSE Syntax

CLOSE cursor_name

This statement closes a previously opened named cursor. Unless closed explicitly, it will be closed at the END of the routine.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top