• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Returning just a STRING from.......

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys. If i run a simple query that returns
5 records each with a column as follows :
select * from tableName
..... returns:
row1 = aaa
row2 = bbb
row3 = ccc
row4 = ddd
row5 = eee
Question : How do i get just a String from the
resultset .Which means concatenating all the
records on the database and returning just one String object from my resultset.
Hence desired result:
String x =aaa + bbb + ccc + ddd + eee ;
All codes and references will be appreciated
NOTE : my actual logic is returning 1000s of records with say 5 columns each and i need all as an object from a query on an Oracle
back end.I donot have a clue how to go about this.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't see how you will accomplish this on the database side, but you can code this:

I know it isn't what you wanted (on the backend) but it will do what you want.
Jamie
[ March 21, 2002: Message edited by: Jamie Robertson ]
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can do one more thing, in your sql statement concatenate all the columns so that you get one column and then rs.getString(1) will give you string of all the five columns
snippet: select col1 || col2 || col3 || col4 || col5 somename from table;
and now as Jamie has given the code append the each row in the result to a stringbuffer object.
Hope this helps
Kareem
 
Kareem Qureshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am sorry i misread your question. You are talking about the rows.
Kareem
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic