This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query failing

 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a strange problem when i am searching with my data base o a column by using java.
My problem is i am using a search which has one field t search like "starts with" or "ends with" or "contains" of a word i am getting user values in a servlet and and building a query based on that my query is

upto now it's fine. i executed this querying my database it is giving 1 record but in my java program it is giving no record why?
My Java code is


Please help me on this
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well if you have included the whole of your method, nowhere do you tell the statement the actual sql string
can you show us how you make the Query

and to improve your select where maw_desc like 'a%r'
 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
k there is nothing wrong with my query generation. some stupid guy entered space after the word so the search is getting failed. but in my sql when execute same query it is automatically trimming space at the end showing result why?
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mallikarjun dontamsetti wrote:k there is nothing wrong with my query generation. some stupid guy entered space after the word so the search is getting failed. but in my sql when execute same query it is automatically trimming space at the end showing result why?


find out how your databases does right trim and do that on the column in the select.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mallikarjun dontamsetti wrote:k there is nothing wrong with my query generation. some stupid guy entered space after the word so the search is getting failed. but in my sql when execute same query it is automatically trimming space at the end showing result why?


have you learnt all of this information since the 1st post, as I find the tone of this message actually quite rude.
You showed us half a snippet of code, said it wasn't returning rows.

As to why your browser is ignoring trailing spaces, how the hell are we supposed to know.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mallikarjun dontamsetti wrote:... but in my sql when execute same query it is automatically trimming space at the end showing result why?


Depends how you are viewing the query results. If you are viewing them via a web browser, it may be that the browser is seeing the output values as normal HTML strings and collapsing the whitespace. And you should probably be stripping trailing spaces from your input values instead of relying on the user to get it right. Garbage in, garbage out.

In general, you should write and test your SQL directly on the database e.g. via your DB's SQL shell or using a proper DB tool (TOAD, SQLDeveloper etc).

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic