Android Question Clone JdbcResultSet to ResulSet

netsistemas

Active Member
Licensed User
Longtime User
This message is a continius and avanced message from

I think move into records from Sql server and this is not posible (view previous link).
My new idea is to clone JDBCResultSet to ResulSet or other object in memory.

Whats is your first initial idea recomended ?
 

OliverA

Expert
Licensed User
Longtime User
1) If you look at the jRDC2 source, the ExecuteQuery2 method of the RDCHanlder class takes the result of an ExecQuery type call and places it in a list of arrays. Each list entry is a record and the array elements are the columns. It has some other code in there to store column names, but than can be stripped out if not needed. You would not even have to keep track of record count, since the number of records would be the size of the list generated.

Link:

2) You could do the above, but instead of storing the information in a list, you could store it in an in-memory SQLite database. Then you would have the ability to query the information to your hearts content. Since the data is locally in memory, re-querying the information will be fast (no trip to the server required). In memory SQLite is used by B4XTable.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
3) If it is a lot of data, store in SQLite locally (not in-memory). Should still be faster than fetching all the data over the network again and again.

4) If all it is (as you mentioned in the previous post) that you need a record count of fetched values, then why not just
B4X:
Cursor = modSQLServer.SQLGetRecordSet("Select count(matricula) from vehiculos")
before doing
B4X:
Cursor2 = modSQLServer.SQLGetRecordSet("Select matricula from vehiculos")
?
Unless there are a lot of changes to the underlying data between the two calls, this may work just as well. The extra call to the server should be negligible to the server.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
5) Actually, for calls that do not have grouping clauses, you can just add an extra column that contains the count of the records returned. Who cares that each record has the same number
B4X:
Cursor = modSQLServer.SQLGetRecordSet("Select count(*), matricula from vehiculos")
or
B4X:
Cursor = modSQLServer.SQLGetRecordSet("Select count(matricula), matricula from vehiculos")
depending on which count result you want (see: https://stackoverflow.com/a/3003533)
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
finally a do it this:
(simil your 1# idea. Thanks OliverA and Erel)


In SQL SERVER is NOT posible do COUNT and get fields in same sql. And this sql command are executed by Sql Server Service in Server machine. But i did not know do this in other sql system.
 
Upvote 0
Top