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

need ideas on multi threaded db update

cj
I have to take all records in a SQL db that have an empty val_code field
and process and update the records with a code number in the val_code field.

The processing is done by sending select info from each record to a
remote server. The remote server returns the code number to be put in
the val_code field. The remote server will allow me to have up to 5
"sessions" open with it at a time.

I'm thinking each "session" will have to be in a separate thread. I
also assume a main thread must exist to interact with the database. Can
anyone give me any other ideas?

Thanks.
Mar 8 '06 #1
6 1247
Hi

Based on my understanding, you will get something from a DB.
And then send request to a remote server which allow 5 "session" and then
update DB.
Can you describe how did you send the request?
Via WebService or anything else?

What do you mean by "session" here?

If you mean a multitheading issue in Winform, we can use the Control.Invoke
to marshal the cross thread call on the main thread.
Safe, Simple Multithreading in Windows Forms, Part 2
http://msdn.microsoft.com/library/de...us/dnforms/htm
l/winforms08162002.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 9 '06 #2
cj wrote:
I have to take all records in a SQL db that have an empty val_code
field and process and update the records with a code number in the
val_code
field.
The processing is done by sending select info from each record to a
remote server. The remote server returns the code number to be put in
the val_code field. The remote server will allow me to have up to 5
"sessions" open with it at a time.


How is the val_code derived from the data? If there are a limited number of
val_code values then you could get them all in one go, or at least implement
a local cache (Array/ArrayList/whatever else might be appropriate) so you
don't have to query the remote server so much.

Are you using one database to update another database on a different
computer, or is it all within the same database? If the latter then surely
it would be more efficient to do it all in a stored procedure in the
database.

Andrew
Mar 9 '06 #3
cj
Thanks Peter and Andrew, I'll try to explain better. The program will
send fields from the records w/o a val_code to the remote server (it's a
soap web service kinda thing but this should be unimportant as it is set
in stone and I have the code necessary to send/receive available) the
response could take milliseconds or several seconds. Records need
processing very quickly. They allow me to have 5 "sessions" (that's the
server folks word for it) open with their server at the same time. I
don't have to wait for the first request to come back to submit another
I can submit up to 5 at a time but each request is done in a seperate
"session" or connection to the server. The only way I see having 5
sessions open on one pc at a time is multiple programs or multiple
threads. Threads being my choice.

I've been thinking since I asked the question (dangerous, I know) and I
see a main thread that launches 5 worker threads. Each worker thread
creates a session and logs in to the server. The main thread meanwhile
pulls a group of records needing validation from the sql server. Then
as long as it has records starts a loop checking to see if worker thread
1 is busy, if thread 1 is the main thread checks worker thread 2, if
it's busy 3 and lets say 3 isn't so it passes the record to worker
thread 3. then picks the next record and check to see if 1 is busy then
2 etc. Each thread would be responsible for updating the sql database
with the changes to the record it was assigned.

To do this I need to know:
--how to reference a thread ie how to know which thread is 1, 2, 3 etc.
--how to set a busy indicator in a worker thread and how to read it
from the main thread
--how to assign a thread a record


cj wrote:
I have to take all records in a SQL db that have an empty val_code field
and process and update the records with a code number in the val_code
field.

The processing is done by sending select info from each record to a
remote server. The remote server returns the code number to be put in
the val_code field. The remote server will allow me to have up to 5
"sessions" open with it at a time.

I'm thinking each "session" will have to be in a separate thread. I
also assume a main thread must exist to interact with the database. Can
anyone give me any other ideas?

Thanks.

Mar 9 '06 #4
cj
Forget this for now--my priorities have been changed.

cj wrote:
Thanks Peter and Andrew, I'll try to explain better. The program will
send fields from the records w/o a val_code to the remote server (it's a
soap web service kinda thing but this should be unimportant as it is set
in stone and I have the code necessary to send/receive available) the
response could take milliseconds or several seconds. Records need
processing very quickly. They allow me to have 5 "sessions" (that's the
server folks word for it) open with their server at the same time. I
don't have to wait for the first request to come back to submit another
I can submit up to 5 at a time but each request is done in a seperate
"session" or connection to the server. The only way I see having 5
sessions open on one pc at a time is multiple programs or multiple
threads. Threads being my choice.

I've been thinking since I asked the question (dangerous, I know) and I
see a main thread that launches 5 worker threads. Each worker thread
creates a session and logs in to the server. The main thread meanwhile
pulls a group of records needing validation from the sql server. Then
as long as it has records starts a loop checking to see if worker thread
1 is busy, if thread 1 is the main thread checks worker thread 2, if
it's busy 3 and lets say 3 isn't so it passes the record to worker
thread 3. then picks the next record and check to see if 1 is busy then
2 etc. Each thread would be responsible for updating the sql database
with the changes to the record it was assigned.

To do this I need to know:
--how to reference a thread ie how to know which thread is 1, 2, 3 etc.
--how to set a busy indicator in a worker thread and how to read it
from the main thread
--how to assign a thread a record


cj wrote:
I have to take all records in a SQL db that have an empty val_code
field and process and update the records with a code number in the
val_code field.

The processing is done by sending select info from each record to a
remote server. The remote server returns the code number to be put in
the val_code field. The remote server will allow me to have up to 5
"sessions" open with it at a time.

I'm thinking each "session" will have to be in a separate thread. I
also assume a main thread must exist to interact with the database.
Can anyone give me any other ideas?

Thanks.

Mar 9 '06 #5
Hi CJ,

Thanks for your update!
If you still have any concern, please feel free to post here.
Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 10 '06 #6
cj,
Forget this for now--my priorities have been changed.

I don't know if I wrote this already to you, I think that to let that be
forever is a good choose, however.

Let the Server do its job by handling the sessions in a proper way, and
don't interfere in that.

Just my thought,

Cor
Mar 10 '06 #7

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

Similar topics

2
by: Mike Rovner | last post by:
Hello, Please advise on multi-threaded list *append*: import time, random, thread aList = def main(): for i in range(10):
0
by: Royco | last post by:
Hi, Situation as follows - a C++ component with OCI-calls running under the control of COM (w2k) - component is marked transactional - the component connects to database1 but wants to update...
0
by: Ganbold | last post by:
Hi, I'm new to multi-threaded programming and reading the book "Programming with POSIX Threads" and trying to understand concepts and coding. What I'm trying to do is to rewrite mysql client...
2
by: Michal Przytulski | last post by:
Hi, I'm looking information abouth runing PHP CLI application in multi-threaded - on http://www.php.net/manual/pl/ref.pcntl.php i found information abouth process control - but is PHP support...
0
by: Stuart Norris | last post by:
Dear Group, I am attempting to write a "splash" and "status" Form using a second thread. I wish to use this Form to display status information to the user when I do CPU intensive work in my...
2
by: Naveen Mukkelli | last post by:
Hi, I'm working on a multi-threaded application. I'm using ThreadPools. One of the requirements of the application is, if certain exception occurs all the counters have to be reset. I have...
1
by: Mullin Yu | last post by:
As subject. I have lots of VB6 dll and ocx files and they are single-threaded as VB6 doesn't support multi-threaded indeed. Can I wrap anything at .NET so that multi-threaded feature can be...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
14
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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
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
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...
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.