Android Question Resultset

Guenter Becker

Active Member
Licensed User
Good Day hopping you are all well,
I have a question concerning Database and Resultset. For Example if I am performing an SQL INSERT or UPDATE the data saved in the database ist changed but the data in the resultset is not!
I understood that this objects are independend from each other and that I can change the content of the Resultset only by a SELECT.
Up to now I am performing the SQL Command and after that I am performing a SELECT to update the Resultset Data. It seems to me that going this way is not efficient if I am working with a Database having heavy Data load (a Million or more records). Allways performing a SELECT to update the Resultset will cost time.

Question:
Anyone knowing a way to insert, delete or update the Resultset by placing the cursor on the row and transfering the values direct to the columns. This question or idea is comming up because I understood that the Resultset is equal to a memory table.
 

DonManfred

Expert
Licensed User
Longtime User
I have a question concerning Database and Resultset. For Example if I am performing an SQL INSERT or UPDATE the data saved in the database ist changed but the data in the resultset is not!
How would anyone help here if we do not know what you are doing.

Using a INSERT or UPDATE query does not change any resultset.

If if you want to get updated data call the Select query again to create a new resultset. Check this resultset then for the updated or new data.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
It seems to me that going this way is not efficient if I am working with a Database having heavy Data load (a Million or more records)
Why you need to call a select for millions datasets? NO USER will EVER want to see millions of rows of data.

What exactly are you trying to archieve? Sound like your database structure is not what you really need.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Ok thank you for your quick response and now step by step...

As you wrote 'do a SELECT' is exactly what I do and what I pointed out in my post.
I also posted that I know that a resultset is not affected by SQL Commands except SELECT.
Sorry but to repeat what I wrote does not help me.

It is not the question what I am doing on a special project. The question is in general important to get knowledge about the best and quickest way to do it. May be that at the end the last answer is 'NO other way than SELECT again'. But I think we are not at this point.

In your 2nd reply you talk about the Database. You are to be right no one will make SELECT with a million of records. That statement was only to point to the background of the question dealing with heavy dataload of databases. In a project there is a database with many thousands of records containing description and sales data of products sold worldwide. On base of this example there are cases where the result of a SELECT will have hundreds or even more than a thousand of records. To examin them or for printout.

At least the question is still open. Conclusion to the audiance Any other Ideas?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Look at Resultset.CONCUR_UPDATABLE
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Look at Resultset.CONCUR_UPDATABLE
Hi, never heard about that. This is not a property of the Resultset Object nor of the SQL Object. Could you give an example /description.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It has to be set from java as I don't think it's in the resultset library.

It allows the resultset to be updated and reflect changes back to the underlying database.

Whereas now we have readString(...) you gain updateString(...,value).
If used with SENSITIVE , the resultset is 'live' and will change with outside database changes.

Not too hard to use, but you have to weigh up the extra effort involved against using select then update queries.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Sounds good but I am not so familar in coding java. I am coding in B4A.
Could you please give an exmple or a place wehre to take one from.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I will try to find the test I wrote (it's on another computer).
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I don't understand the question.
After you issue a SELECT command, the returned resultset is used for reading.
It is not intended for writing.
I never come across the need to write to this temporary data.
If I want to, I can issue another SQL command.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Doesn't look like sqlite supports Resultset.TYPE_SCROLL_SENSITIVE or Resultset.CONCUR_UPDATABLE.

I was using it on a different database.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Ok thank you
 
Upvote 0
Top