473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Locking table?

Hi,

I've got two tables that control my menu on my site (which is coded in ASP).
The first table (cam_menu) contains info about the sort order of the menu
and the second about my content. To insert a menuitem above a previous
menuitem I use these SQL-sentences:

'## Select id to insert new menuitem above
strSelectidSQL = "SELECT * FROM cam_menu WHERE id = " & intActionid & ""
Set SelectidRS = Conn.Execute(strSelectidSQL)

'## Add 1 to menu_sortorder for menuitems with a menu_sortorder greater than
or equal to
'## the one were inserting above AND where the parent_id equals the one
we're
'## inserting above
strUpdateidInfoSQL = "UPDATE cam_menu SET menu_sortorder = menu_sortorder+1
WHERE parent_id = " & SelectidRS("parent_id") & " AND menu_sortorder >= " &
SelectidRS("menu_sortorder") & ""
Conn.Execute(strUpdateidInfoSQL)

'## Insert new menuitem
strInsertNewidSQL = "INSERT INTO cam_menu(parent_id,menu_sortorder) VALUES("
& SelectidRS("parent_id") & "," & SelectidRS("menu_sortorder") & ")"
Conn.Execute(strInsertNewidSQL)

SelectidRS.Close
Set SelectidRS = Nothing

'## Select last inserted id
strSelectLastInsertedRecord = "SELECT LAST_INSERT_ID() AS intLastId FROM
cam_menu"
Set LastRecordRS = Conn.Execute(strSelectLastInsertedRecord)

'## Insert record into cam_content table
strInsertIntoContentSQL = "INSERT INTO cam_content(id, lng, show_status,
content_name, module_id) VALUES (" & LastRecordRS("intLastId") & ",'" &
Session("language") & "'," & strInsertMenuShowStatus & ",'" &
strInsertMenuName & "'," & strInsertContentModule & ")"
Conn.Execute(strInsertIntoContentSQL)

LastRecordRS.Close
Set LastRecordRS = Nothing

Now, this works fine and by using LAST_INSERT_ID() I won't get any conflicts
in the content table if two (or more for that matter) user(s) are inserting
a new menuitem at the same time, however that won't be the case for the
cam_menu table as far as I can see when it update the records that already
exists. Do I need to lock the tables or are there a better way of doing
this?

Also, if I need to lock the tables, how would I do that? And it has to be
done so two (or more) users can insert a menuitem at the same time, but
still not create any conflicts, which I guess means that User B has to wait
for User A's queryies to complete before executing.

Hope I'm making myself understandable, otherwise feel free to ask for more
info.

Best regards, Jacob
Jul 19 '05 #1
0 1486

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve McWilliams | last post by:
Hello, I am relatively new to MySql (4.0.14) but I have read through the relevent documentation and am still confused about how row level locking behaves with InnoDB tables. I created a...
12
by: Puvendran | last post by:
Hi, We have encountered deadlock on a table which is used to generate sequential numbers for different categories eg typical entries Category Value TRADE_NO ...
3
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often...
9
by: john smile | last post by:
Hi All, I want to lock 2 tables on 2 servers using TABLOCKX hint. These tables function as semaphores in my application. It means when the tables are locked then other users will not be able to...
2
by: Randall Sell | last post by:
Hello all, Somewhere on these newsgroups I recall reading that SQL Server 6 and prior (when they were married with Sybase) used page locking and not row level locking. Hence you could be locking...
16
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
0
by: brijeshmathew | last post by:
Hi I use Visual Basic 6, Service Pack 6, Microsoft ActiveX Data Objects 2.8 Library(msado15.dll) and access 2000 database using JET 4 OLE. I have an application that adds records simultaneously...
0
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
7
dlite922
by: dlite922 | last post by:
I need to do some sort of Locking mechanism at interface level, instead of DB Level. I know how MySQL table locking works, but that won't work in my scenerio. Requirements: When someone is...
0
by: MADAM | last post by:
We have a table PLPF.ARCLOBTB that we are considering changing from page level locking to row level locking to minimize the number of abends on batch jobs because of timeouts. There is a column...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.