Page 1 of 1

Not an error but help required

Posted: Tue 20 Sep 2016 20:46
by taoh15
Hi
I'm not sure if I should be posting this here but I'll ask anyway

I have a remote database on another continent and I have to update all the records in one of the tables regularly using Delphi Seattle, UniDac and Securebridge.

The database (not of my design ) has approx. 21,000 records and one of the fields is an integer field which contains a value used as the sort order which is dependant on three other fields. I have to reorder the table reqularly for reasons beyond my control and to do this i fetch the records with
SELECT id,ordering from mytable order by surname,forename,dob.
I then have to have to go through the whole table updating ordering with the position the record is in the query.
I've worked with SQL databases for many years but they have always been small and fairly local or I was able to have a program on the server to do this for me. This is the first time I've needed to do an update of this magnitude on a server which is linux and on a hosted shared server.
So I would like suggestions on the fastest and safest way of doing this using the above mentioned components.
I would guess that the last thing thing I need to be doing is editing each record individually, so I would further guess that I make up a list of 'UPDATE mytable SET ordering=x WHERE id=xx;' but what is the best way to get them back to the server or is there some other way of doing this.

Thank You
Niall

Re: Not an error but help required

Posted: Thu 22 Sep 2016 15:49
by swierzbicki
Why don't you use a store procedure for this ?
You can either CRON a call to this stored procedure or even call this stored procedure from your software.

Re: Not an error but help required

Posted: Sat 24 Sep 2016 10:54
by taoh15
Oh How I wish it was that simple. It's actually a lot more complicated than that.
The data starts of live in an Access database, which is converted to MySql and uploaded to a server in Scotland.
Then that database has to update a server in Bosnia.
All the usual replication doesn't work as the two macros I wrote into the Access database keep failing as do some of the built in access functions, like an autoinc field stops autoIncing leaving the field along with the datecreated and lastmodified fields with a value of null which scuppers every field needed for normal comparison. I need the author over to using something other that access databases. Just to make it worse the blasted Access Data is on a Memory stick.

Cheers
Taoh

Re: Not an error but help required

Posted: Thu 10 Nov 2016 13:55
by ViktorV
You can use the TCRBatchMove component, which allows to transfer data between different datasets. More detailed information about it you can find in our documentation: https://www.devart.com/unidac/docs/?dev ... chmove.htm
Also, you can increase performance of working with the database using Batch Operations. See more details about using Batch Operations in our products in our blog: http://blog.devart.com/using-batch-oper ... nents.html