This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get id of column values/content

 
S Roberts
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i get id from db table for each column values with java or oracle query? i had before each column values and now i need the id of this column values



with li = line.split(","); i got the values that then will be given to p.setLid(li[i]); and iterate, but now i want to get id from the table in db where this values stored with id instead of this column values, how can i do it, with query like:



or what can i do else, please any help, have no idea how to do this
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like you're asking a question about SQL, but then you show Java code for parsing text, so I'm confused. If your question is: for a database table named MY_TABLE with fields named ID and VALUE, how can I find the ID for a given VALUE? ... then the SQL is:



Note that unless there is some sort of unique index on the VALUE field, you could get back more than one ID from this query.
 
S Roberts
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you vor answering, i mean i have this java code with it i read csv files from folder and then load the data from this files in this folder, and hier with line li = line.split(","); i get the values that i have in csv file and split them and become in li the value name, and then in else block i create a P objekt where i set this values from this csv files, and with p.setLid(li[i]); i set the value for all valuenames, and then get these value names in separate column with other content from this csv, and my question is, i need do this with db, and write these csv file values to the table in db (it will be done with another java class), what i need, that to write the ids of these values into the table in db, instead of valuename, and while there is no ids for valuenames, i need to get the id from the table in db where these are already listed with sequences, and i don't know how can i write in data table the id of this valuenames and other content, this data table should contain the ids of valuenames timestamp values and again the ids of the csv files, i don't know how to do this with the ids, i must get the ids from the db table and then set these on p.setLid(li[i]); where i set early the valuenames, simple instead of valuenames i should set it so that will set ids automatically for all these valuenames, i hope its in any kind of understadable
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I'm sorry. I don't understand that at all. I get that you are reading files, and in some way want to update a database table. You'll need to be clearer about your specific goals though.
 
Paul Clapham
Sheriff
Posts: 21576
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't understand most of that either, but let me make a couple of guesses:

(1) The first line of the CSV contains the column names of the table represented by the rest of the CSV.

(2) The requirement is not to get data from the database, but to write data into the database.

Are either of those two things correct?
 
S Roberts
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes 1) is right, and i need to get id from db table and then write it in another table in this db, 2) its however to get ids from seqeunced ids and then write this in this another table instead of the csv valuenames in first column
 
S Roberts
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.
 
S Roberts
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to use JDBC to fetch data from the database?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic