MySQL Forums
Forum List  »  Stored Procedures

Re: While loop with Dynamic SQL
Posted by: Peter Brawley
Date: November 16, 2014 05:27PM

> How would you do this as opposed to doing it one at a time and how would you write this without the proc?

Sprocs are a bitch to write, debug & maintain, and in MySQL usually offer zero performance advantage. So in MySQL, the SQL Server rule of encapsulate if possible does not apply.

SQL is set-based. If a job entails row-to-row logic or recursion, you probably need to write an sproc. Such row-to-row processing is s-l-o-w. Your task appears to target a set of rows. So the initial assumption should be: it can be done with one or two SQL commands.

Rather than me do it for you, see if you can write a Select statement that defines the job rowset. Once you have that debugged, it should be pretty easy to derive the required Insert statement.

Options: ReplyQuote


Subject
Views
Written By
Posted
15578
November 14, 2014 07:21PM
2204
November 14, 2014 07:27PM
1853
November 16, 2014 12:32PM
2030
November 16, 2014 01:28PM
1532
November 16, 2014 02:55PM
1521
November 16, 2014 03:06PM
Re: While loop with Dynamic SQL
1563
November 16, 2014 05:27PM
1647
November 17, 2014 11:19PM
1729
November 16, 2014 04:44PM


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.