473,385 Members | 1,893 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,385 software developers and data experts.

Query and Synchronization...

Hi people!
I was writing a function in which I execute a query to READ some
value, and another one to UPDATE the previous query related data.

i.e.
query-select * from ..... to retrieve myvalue
read myvalue
change myvalue
query-update myvalue

Suddenly I had a doubt...
Can 2 or more browsers call the same function at "same time" and start
the UPDATE query with some still uncomputed data? or is the function
synchronized?
In positive case, should I use some mechanism as Semaphore?
tnx in advance, Giovanni

Apr 25 '07 #1
2 1296
Rik
Giovanni wrote:
Hi people!
I was writing a function in which I execute a query to READ some
value, and another one to UPDATE the previous query related data.

i.e.
query-select * from ..... to retrieve myvalue
read myvalue
change myvalue
query-update myvalue

Suddenly I had a doubt...
Can 2 or more browsers call the same function at "same time" and start
the UPDATE query with some still uncomputed data? or is the function
synchronized?
Well, 'uncomputed data', no... They can overwrite each others changes
though. Most of my systems aren't that busy, so I opt for:
UPDATE table SET field1=..., field2=... WHERE field1=..., field2=...

If there's no row updated, report the record has been changed, and ask
the user again...

--
Rik Wasmus

Estimated date being able to walk again: 01-05-2007.
Less then a week, hurray!
Apr 25 '07 #2
That's the situation... I've to grant round robin algho in a small
number of records i.e. 20...
The operations are theese:
MYSQL->select id,ticket
PHP-search ticket=true
MYSQL-SET ticket=false with id=ID
MYSQL-SET ticket=true with id=nextticket_at_id();

semaphore could help me?

I was thinking to change strategy...
I wisha use datetime type to retrieve the oldest record not retrieved,
and so update it with NOW()
selecting the record in age order and limiting to 1 i could have what
I want...
dont'you think?

Apr 26 '07 #3

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

Similar topics

4
by: scott | last post by:
hi all, Thx to any one that can offer me help, it will be much appreciated. iv got a multithreaded program and need to use thread synchronization. The synchronization does not have to...
0
by: Rod | last post by:
I orginally posted this to microsoft.public.sqlserver.ce but had not received any responses. I have a CF.NET application (C#) with a SqlCE database. We had originally planned to use SQL...
12
by: emma_middlebrook | last post by:
Hi Say you had N threads doing some jobs (not from a shared queue or anything like that, they each know how to do their own set of jobs in a self-contained way). How can you coordinate them so...
0
by: lbrtchx | last post by:
Say you need to serve the same Web content from a number of IP address, which you need to keep out there with high availability requirements ~ I think Web Services would be a good candidate for...
0
by: sundman.anders | last post by:
Hi all! I have a question about thread synchronization and c++ streams (iostreams, stringstreams, etc). When optimizing a program for a multicore processor I found that stringstream was causing...
15
by: shapper | last post by:
Hello, I have two Lists: A = {ID, Name} = { (Null, John), (Null, Mary), (Null, Andrew), (Null, Peter) } B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4, Andrew) } I want to...
3
by: CKKwan | last post by:
Dear All, Can synchronize a class, any function is called and the entire class is locked. Can synchronize a method What if I need to Lock a class only when specific method is call?
0
by: Timothy Grant | last post by:
On Mon, Aug 18, 2008 at 10:58 PM, tarun <tarundevnani@gmail.comwrote: Does making it a class level instead of instance level variable not work? -- Stand Fast, tjg.
15
by: ingejg | last post by:
I am starting to study internet synchronization, and my head is still spinning since internet is not my forte, however my boss is breathing down my neck at the moment. Our company has only one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.