MySQL Forums
Forum List  »  Stored Procedures

Re: table locks in cursor. how it works?
Posted by: Yurii Korotia
Date: September 30, 2012 01:53PM

Rick James Wrote:
-------------------------------------------------------
> * Try to avoid cursors. They are much less
> efficient than if you can handle many rows in
> single statements.
>
> * SELECT ... FOR UPDATE -- This is often all you
> need for locking.
>
> * "Table" locks should be avoided in InnoDB; the
> automatic locking is almost always sufficient.
>
> What does the SP do? Would you like to show it to
> us? Also SHOW CREATE TABLE, SHOW CREATE VIEW, and
> anything else relevant.

hello

there are about 500 lines of code and it has some sensitive data.

In short, sp does next:

0. declares cursor for view we are going to create with "select ... for update" (on view)
view will be built from 4 tables
1. checks user input. variables may be var or null (where null is everything, so we need to create statement)
As we have 5 variables, that's 25 combinations.
2. prepare statement
3. execute statement. view is created
4. open cursor on view
5. loop view
- start transaction
- and do custom task on each record.
- commit
6. if any task fails we rollback last transaction.
7. finish with status


so, i did everything you said not to do.

Options: ReplyQuote


Subject
Views
Written By
Posted
5616
September 24, 2012 02:37AM
2162
September 28, 2012 01:35PM
Re: table locks in cursor. how it works?
2017
September 30, 2012 01:53PM


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.