MySQL Forums
Forum List  »  Microsoft SQL Server

Re: Migrate a store proc from MSSQL to MySQL
Posted by: Dmitry Tolpeko
Date: March 06, 2011 01:30PM

The SP is quite easy but there are several issues:

- replace [] with `` in identifiers (or do not use delimiters at all)
- change @ to v_ (to not confuse parameters/local variables with column names)
- remove dbo.
- convert getdate() to current_timestamp
- convert END to END IF

The result should look like this:

DELIMITER //
CREATE procedure usp_save_etl_error(v_mlsboard_id INT
 ,v_mls_id VARCHAR(50)
 ,v_is_data TINYINT 
 ,v_is_picture TINYINT
 ,v_message VARCHAR(1000))
begin

   IF NOT EXISTS(SELECT 1 FROM mlsassistant.etl_error WHERE mlsboard_id =  v_mlsboard_id AND mls_id = v_mls_id AND is_fixed = 0) then

  INSERT INTO mlsassistant.etl_error(mlsboard_id, mls_id, is_data, is_picture, is_fixed, message, create_date)
VALUES(v_mlsboard_id, v_mls_id, v_is_data,
v_is_picture, 0, v_message, CURRENT_TIMESTAMP);
   end if;

end;
//

You can convert data types, built-in functions in stored procedures online at http://www.sqlines.com/online or use SQLWays at http://www.ispirer.com/ for complete conversion.

Thanks,

Dmitry

Options: ReplyQuote


Subject
Written By
Posted
Re: Migrate a store proc from MSSQL to MySQL
March 06, 2011 01:30PM


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.