views:

18

answers:

1

I am trying to insert data into a InnoDB MySQL table which is locked using an alias and I cannot for the life of me get it to work!

The following works:

LOCK TABLES Problems p1 WRITE, Problems p2 WRITE, Server READ;
SELECT * FROM Problems p1;
UNLOCK TABLES;

But try and do an insert and it doesn't work (it claims there is a syntax error round the 'p1' in my INSERT):

LOCK TABLES Problems p1 WRITE, Problems p2 WRITE, Server READ;
INSERT INTO Problems p1 (SomeCol) VALUES(43534);
UNLOCK TABLES;

Help please!

A: 

Use INSERT INTO Problems (SomeCol) VALUES(43534);
No p1...

Gary
Thanks for the suggestion, but I have already tried this. Due to the fact that the lock is done with an alias (which I need to do) and INSERT doesn't reference the alias at all you get an error 'Table 'Problems' was not locked with LOCK TABLES'
Whitey