Forums Register Login

Regarding updating Database from Text file.

+Pie Number of slices to send: Send
Hi Ranchers.

I am not sure is this the right forum for this question.

I am trying to come up with a logic for a small utility. Bascially I need to run a java program that will call a Stored Procedure to insert records
into a table from a text file which has several hundred rows. If the rows are being appended to the text file everytime to the existing rows how can I know until which rowcounts I have updated last time to the database after the program runs.I mean if I have updated 1-100 row the first time how can I keep track so that I will start updating from the 101 row on the next run. Do you think I should keep an indicator which updates the text file so that next time I will know which rows have been updated. Or is there anyother mechanism to do this relatively easily.

Please advise. Thanks in advance.

Bhazee
+Pie Number of slices to send: Send
Hi Prem,

how about processing the whole file in one run, line by line, and then renaming it to some name that indicates to your tool the file is done. Finally, put an empty file with the same name as your data file originally had, so newly arriving data can be appended to it.

If your tool is the only thing that modifies the database, you might also use SELECT count(*) to dertermine the number of tupels already in the database table, and skip an according number of lines in the file.

Yet another option would be using timestamps.
+Pie Number of slices to send: Send
Guido

Thanks for your information. Also when you mentioned about Timestamps just wondering what you had in mind.Just trying to come up with the best approach.

Thanks
Bhazee
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1063 times.
Similar Threads
Deleting a row in Jtable as well as from the .txt database
Best option to update only selected rows form Struts2
Action Class or Regular Java Class to use?
Trouble with model for calculating and adding table values dependent on multiple rows
Update based on Row id
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:15:33.