473,800 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(st rSelectidSQL)

'## 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
strUpdateidInfo SQL = "UPDATE cam_menu SET menu_sortorder = menu_sortorder+ 1
WHERE parent_id = " & SelectidRS("par ent_id") & " AND menu_sortorder >= " &
SelectidRS("men u_sortorder") & ""
Conn.Execute(st rUpdateidInfoSQ L)

'## Insert new menuitem
strInsertNewidS QL = "INSERT INTO cam_menu(parent _id,menu_sortor der) VALUES("
& SelectidRS("par ent_id") & "," & SelectidRS("men u_sortorder") & ")"
Conn.Execute(st rInsertNewidSQL )

SelectidRS.Clos e
Set SelectidRS = Nothing

'## Select last inserted id
strSelectLastIn sertedRecord = "SELECT LAST_INSERT_ID( ) AS intLastId FROM
cam_menu"
Set LastRecordRS = Conn.Execute(st rSelectLastInse rtedRecord)

'## Insert record into cam_content table
strInsertIntoCo ntentSQL = "INSERT INTO cam_content(id, lng, show_status,
content_name, module_id) VALUES (" & LastRecordRS("i ntLastId") & ",'" &
Session("langua ge") & "'," & strInsertMenuSh owStatus & ",'" &
strInsertMenuNa me & "'," & strInsertConten tModule & ")"
Conn.Execute(st rInsertIntoCont entSQL)

LastRecordRS.Cl ose
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 1506

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

Similar topics

0
3237
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 database with a single innodb table which has 2 columns, one of which is indexed. The locking behavior I see when I test against this database is that it uses row level locks if the "SELECT ... FOR UPDATE" involves the indexed column, but uses table...
12
9577
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 1456 JOB_NO 267 .....
3
5125
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 the users (when they bother to tell me) find that the application locks up and they are unable to work. No errors are produced (error trapping in the app is good). They 'shout round' to each other and get someone to exit the data entry screen....
9
5070
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 access them and automatically they can not continue their works. I have tried using the following code, but it does not work. I always got the error :
2
6875
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 a lot more records then what you think when doing an UPDATE or INSERT SQL. Now I notice that SQL Server 7 and 2000 claim to use row level locking. (As you can see, I have been out of the SQL arena for some time). So what I'd like to know if...
16
8935
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
0
2098
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 to the same table. During the simultaneous add and update, a Locked error occurs, and most of the times it locks all the machines. I have been reading on Microsoft Site and on google groups that JET4 and ADO have fix for page locking , which...
0
4103
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 with "No locks" as the default, so that optimistic record locking should take place, and "Open databases using record-level locking" is selected. Each Java thread gets a new connection to the database, then updates its record. One of my users has...
7
1857
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 editing a case, for example changing the persons info, editing the violations/charges they have, etc... I don't want another user to have pulled the same case and one of them clicks Update or Save before the other. So the case is locked for...
0
1251
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 on this table with a type of CLOB. The manual indicates that you can't have row level locking on a CLOB tablespace but it does not mention anything about a CLOB column. Is is possible to have row level locking on this table and is there anything...
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.