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

sql query error

 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m using this sql query in my project... is it showing an error..

sql query..


error is..

"Count field incorrect in SELECT command"

please help..
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kunal,

I don't know this error message, but I would change your sql statement to this:



Maybe your problem was that your subselect returns more than one value?


John
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks dude..
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use a variable directly into a SQL statement..


str is a String variable.. can it be done or i have to use the preparedStatement and setString() function..?
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you think of dynamically composing your query you can do this.

But you should not. Working with parameters and setting these parameters enables the database to parse the select statement only once and then use the parsed statement with different parameters.

I'm not sure if this is an answer to your question...
 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my query is dynamic.. the value of "str" is being taken from a jframe using getText() method. so the value will change according to the input on the jframe window by the user.. is it necessary to use the PreparedStatement or can i use the normal Statement object.. please explain..



will this create any error..??
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you could use both, with Statement I could think of something likethis:



As I wrote before I would prefer this:



 
kunal vermaa
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.. i also prefer the 2nd method..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic