----- Original Message -----
> From: "Adarsh Sharma" <adarsh.sha...@orkash.com>
> 
> Today I noticed some duplicacy in my c_id column which is not

Yes, that's what you get if you don't use auto_increments.

> I need multiple client select cid from 2 tables & insert data with
> adding 1 to previous C_id  in isolated manner.
> I think I need to use lock  statements in my procedure.

Locks will utterly kill your performance. It's already a lot lower than it 
could be because you're doing selects prior to every insert.

> Can anyone suggest how to solve the issue.

Kick the guy who writes the business requirements in the balls, hard. Then 
explain that some things are not to be messed with, and he can't get what he 
wants this time. Kick him again, then add an auto_increment. Make sure to use 
sharp-tipped shoes.

Failing that (damn his iron codpiece) you can look at "cheating" and faking the 
Oracle concept of sequences using a separate table with just an auto_increment 
field.

Drupal (the older versions like 5, at least) also does not use auto_increments 
on MySQL iirc, you could have a look at their code to see how they solved the 
problem. I suspect they also emulate sequences somehow.

If you *really* feel like reinventing the wheel, write a stored procedure to 
process your updates using something like the hot potato or bankers' algorithm.


-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to