The error is in your insert statement:
for(var i=0;i<item.invocationResult.resultSet.length;i++){
WL.Logger.debug(i+")Sto inserendo " + item.invocationResult.resultSet[i].titolo + "," + item.invocationResult.resultSet[i].autore + "," + item.invocationResult.resultSet[i].id_categoria);
tx.executeSql("INSERT INTO canti(titolo,autore,id_categoria,testo) " +
"VALUES('"+item.invocationResult.resultSet[i].titolo+"','" +
+item.invocationResult.resultSet[i].autore+"','" +
+item.invocationResult.resultSet[i].id_categoria+"','" +
+item.invocationResult.resultSet[i].testo+"')");
}
Observe the following lines:
+item.invocationResult.resultSet[i].titolo+"','" +
+item.invocationResult.resultSet[i].autore+"','" +
+item.invocationResult.resultSet[i].id_categoria+"','" +
+item.invocationResult.resultSet[i].testo+
You have included a '+' at the beginning of each line AND at the end of the previous line. The first '+' will be used as string concatenation, but the second '+' will be interpreted by javascript as a 'convert to integer'.
For example if you type the following into your javascript debugger:
+"54"
the result will be '54', since this is saying "convert the string '54' into an integer"
However if you type this:
+"hello"
the result will be NaN, since "hello" cannot be converted into an integer.
So the solution is to use this instead:
for(var i=0;i<item.invocationResult.resultSet.length;i++){
WL.Logger.debug(i+")Sto inserendo " + item.invocationResult.resultSet[i].titolo + "," + item.invocationResult.resultSet[i].autore + "," + item.invocationResult.resultSet[i].id_categoria);
tx.executeSql("INSERT INTO canti(titolo,autore,id_categoria,testo) " +
"VALUES('"item.invocationResult.resultSet[i].titolo+"','" +
item.invocationResult.resultSet[i].autore+"','" +
item.invocationResult.resultSet[i].id_categoria+"','" +
item.invocationResult.resultSet[i].testo+"')");
}
Not tested, but you get the idea.
Also, since you have Worklight tagged on this questions, I'd highly recommend looking into JSONStore for your local storage needs.