Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding updating Database from Text file.

 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Guido Sautter
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic