mysql: sending many commands

henry1311

Member
Licensed User
Longtime User
ENGLISH
-------
Hello everyone.
In my project I download data from a mysql database (select * from table1 ...), I have to update them and processes them according to specific conditions.
In the database there are currently about 10000 records and will tend to increase.
The problem is sending many commands UPDATE, processing can also be 3000/4000/5000 records to update.

I tried sending a command at a time:
update table1 field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=x1
repeated 3000 times with x1 always different (but not consecutively!)
- The first few records (5 / 6 or 7) are updated, then only a few ... example 10, 100, 200 ...
I also tried to put a 'waiting for 1 or 2 seconds', but ... same processing as well as lengthen impossbile 3000 seconds!

I tried sending a group of commands at a time:
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 1;
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 3;
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 10;
and
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 1;
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 3;
update table1 field1 = value1, field2 = value2, field3 = value3, field4 = value4, field5 = value5 where serial = 10
- Ii return me the sql error message:
You have an error in your SQL syntax; check the manual That corresponds to your MySQL server version for the right syntax to use near 'UPDATE tyacqua
update tyacsta = '0001-01-01 ', tyacdla '0001-01-01', tyaclea = 0, tyaccm 'at line 2
stops at about 230 character!
As you can see the command does not terminate properly: it should continue with tyaccme=0, tyacste='0001-01-01 '...
However, the syntax is correct because if I take 20 commands UPDATE ... and they run it in phpmyadmin are processed correctly.

Basic4Android the code I use is:
query = "update ..."
creq = "http://192.168.1.2/ws.php"
req.InitializePost2 (creq, query.GetBytes ("UTF8"))
'Timeout = 60000' set timeout to 10 seconds
RequestID = 1
hc.Execute (req, RequestID)
---> I also tried with RequestID=RequestID+1 to each command or command group!

The page php webservice is the same as in the tutorial Erel (countries.php) and in any case the main command is
...
$ Query = file_get_contents ("php: / / input");
...
$ Sth = mysql_query ($ query) or die ("ERROR:". Mysql_error ());
...

How do I solve the updating of 3000/4000/5000 records in the mysql database remote or local?

Greetings to all.
Enrico
:sign0085:


ITALIANO
--------
Ciao a tutti.
Nel mio progetto scarico i dati da un database mysql (select * from table1...), li elaboro e li devo aggiornare secondo condizioni.
Nel database attualmente ci sono circa 10000 records e tenderanno ad aumentare.
Il problema è nell'invio di molti comandi update, nell'elaborazione possono essere anche 3000/4000/5000 records da aggiornare.

Ho provato con l'invio di un comando per volta :
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=x1
ripetuto 3000 volte con x1 sempre diverso (ma non consecutivo!)
- i primi record (5/6 o 7) vengono aggiornati, poi soltanto alcuni... esempio il 10, 100, 200...
Ho provato pure a mettere un 'attesa di 1 o 2 secondi', ma... stessa elaborazione, oltre che impossbile allungarsi i tempio di 3000 secondi!!!

Ho provato con l'invio di un gruppo di comandi per volta :
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=1 ;
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=3 ;
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=10 ;
e con
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=1 ;
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=3 ;
update table1 set field1=value1, field2=value2, field3=value3, field4=value4, field5=value5 where serial=10
- mi ritorna l'errore sql :
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE tyacqua

set tyacsta='0001-01-01', tyacdla='0001-01-01', tyaclea=0, tyaccm' at line 2
si interrompe a circa il 230esimo carattere!
come si nota il comando non termina correttamente : dovrebbe continuare con tyaccme=0, tyacste='0001-01-01'...
La sintassi comunque è corretta in quanto se prendo i 20 comandi update... e li eseguo in phpmyadmin vengono elaborati correttamente.


Il codice basic4Android che utilizzo è :
query="update ..."
creq="http://192.168.12/ws.php"
req.InitializePost2(creq, query.GetBytes("UTF8"))
'Timeout = 60000 'set timeout to 10 seconds
RequestId=1
hc.Execute(req, RequestId)

---> Ho provato pure con RequestId=RequestId+1 ad ogni comando o gruppo di comandi!

La pagina php del webservice è la stessa dell'esempio del tutorial di Erel (countries.php) ed in ogni caso il comando principale è
...
$query = file_get_contents("php://input");
...
$sth=mysql_query($query) or die ("ERRORE : ".mysql_error());
...

Come posso risolvere l'aggiornamento di 3000/4000/5000 records nel database mysql remoto o locale?

Un saluto a tutti.
Enrico
 
Top