MySQL Forums
Forum List  »  Stored Procedures

Re: changing Mssql sp to Mysql sp
Posted by: vinod d
Date: June 13, 2013 04:19AM

hi,

I have Changed to Mysql SP but this inserts null values to all fields in three rows in table can anybody help

BEGIN
    DECLARE _DataRow VARCHAR(21000);
	 DECLARE _DescriptionOfWorkDone VARCHAR(21000);
    DECLARE _TemporaryStorage VARCHAR(21000) ;
    DECLARE _QTY int;
    DECLARE _Total int;
    DECLARE _CurrentField int;
	
    WHILE INSTR(_DelimitedString, ';') > 0 DO

	    SET _DataRow = CAST(SUBSTRING(_DelimitedString, 0, INSTR(_DelimitedString,';' )) AS CHAR);
	    SET _CurrentField = 1;
	    WHILE INSTR(_DataRow,',' ) > 0 DO  	      
		    SET _TemporaryStorage = CAST(SUBSTRING(_DataRow, 0, INSTR(_DataRow,',' )) AS CHAR);
		    IF _CurrentField = 1 then
		        SET _QTY = CAST(_TemporaryStorage AS UNSIGNED);
                    elseIF @_CurrentField = 2 then
			SET _DescriptionOfWorkDone = _TemporaryStorage;
                    elseIF _CurrentField = 3 then
	                SET _Total = CAST(_TemporaryStorage AS UNSIGNED)	;	
						 end if;	
		    SET _DataRow = SUBSTRING(_DataRow, INSTR( _DataRow,',') + 1, LENGTH(_DataRow));
		    SET _CurrentField = _CurrentField + 1;
		END while;
	    INSERT INTO tblWorkDone (QTY, DescriptionOfWorkDone, Total) VALUES (_QTY, _DescriptionOfWorkDone, _Total);
	    SET _DelimitedString = SUBSTRING(_DelimitedString, INSTR(_DelimitedString,';' ) + 1, LENGTH(_DelimitedString));
       
	   END WHILE;
END


CALL `sp_InputWork`('1,TEST,100;2,TEST1,200;3.TEST3.300;') 

Options: ReplyQuote


Subject
Views
Written By
Posted
2875
June 12, 2013 03:13AM
Re: changing Mssql sp to Mysql sp
1223
June 13, 2013 04:19AM
1196
June 15, 2013 08:49AM


Sorry, you can't reply to this topic. It has been closed.

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.