Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 04-10-2008, 02:34 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
Ah nice one Chris. Yeah that explains it well.
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 04-10-2008, 03:07 PM
Chris.Brown.SPE's Avatar
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
Take a look at this,

Code:
public static void main(String[] args) { String statement = "update employee\nset wtKey = name||pno||id\nwhere id is not null"; String concat = ""; String[] temparray, temparray2, temparray3; temparray = statement.split("=.?");//splits off equals sign and space afterwards temparray2 = temparray[1].split("\\n");//splits off last line concat = temparray2[0];//grabs the concat part of it temparray3 = concat.split("\\|\\|");//splits up by || concat = " CONCAT(" + temparray3[0] + "," + temparray3[1] + "," + temparray3[2] + ")";//puts concat together statement = temparray[0] + "=" + concat + "\n" + temparray2[1];//reassembles statement System.out.println(statement);//output statement }
Output:
update employee
set wtKey = CONCAT(name,pno,id)
where id is not null
Bookmark Post in Technorati
Reply With Quote
  #23 (permalink)  
Old 04-10-2008, 03:10 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,578
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
What this mean pal.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #24 (permalink)  
Old 04-10-2008, 03:17 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
Its the desired SQL query output he was looking for.... Good work Chris.
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #25 (permalink)  
Old 04-10-2008, 03:29 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,578
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ah, I got it.

Users better to mentioned some tips if the thread goes for more than one page, isn't it Don.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #26 (permalink)  
Old 04-10-2008, 09:51 PM
Member
 
Join Date: Apr 2008
Posts: 4
raghu408 is on a distinguished road
Chris that's so nice of you but my API here should be dynamic i.e not specific to one SQL like i mentioned above:update employee\nset wtKey = name||pno||id\nwhere id is not null

but if you send a valid query like:
SELECT region_name || ' ' || store_name FROM Geography
WHERE store_name = 'Boston';

Then it should return:

region_name || ' ' || store_name

basically it should return all that are connected with ||
Bookmark Post in Technorati
Reply With Quote
  #27 (permalink)  
Old 04-10-2008, 11:55 PM
Chris.Brown.SPE's Avatar
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
Try this out.

Code:
static String compute(String temp) { String concat;//holds final concat String[] temparray;//holds parts after split String first, second, third;//divides three parts into three strings temparray = temp.split("\\|\\|");// splits up by || first = temparray[0].substring(temparray[0].lastIndexOf(' ', temparray[0].length() - 2) + 1);//takes off first part by removing everything past last space second = temparray[1];//second part goes into string if (temparray[2].indexOf(' ', 1) < temparray[2].indexOf(10, 1) | temparray[2].indexOf(10, 1) == -1) {//takes last part by removing everything until first space or line feed third = temparray[2].substring(0, temparray[2].indexOf(' ', 1));//in case of space } else { third = temparray[2].substring(0, temparray[2].indexOf(10, 1));//in case of line feed } concat = first + "||" + second + "||" + third;//builds the concat info return concat; }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Parse int to a string variable raj reddy Java Servlet 5 Yesterday 02:30 PM
i need an example of JSR179 ((Location based Ser)implementation for CDC based device talk_to_vivekmishra CDC and Personal Profile 1 06-22-2008 10:45 PM
how to Parse int to a string variable (pls hlp) raj reddy Threads and Synchronization 5 06-10-2008 07:32 AM
difference between code based security and role based security boy22 New To Java 1 07-24-2007 12:59 AM
Parse XMLfile as String using SAX parser Jack XML 2 07-04-2007 10:17 AM


All times are GMT +3. The time now is 03:59 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org