| Author |
help in sql
|
Mary Wallace
Ranch Hand
Joined: Aug 25, 2003
Posts: 138
|
|
I have a sql statement like this pin and account number is not passing the values. system .out print is showing this select pin,emp_acct_no,attn_name,address_line1,address_line2,po_box_no,city,state,zip,country_code,emailFROM w_employer WHERE pin= 'pinum' and emp_acct_no=checkaccountNumber DB Connection Error(validate accountnumer): java.sql.SQLException: ORA-00923: FROM keyword not found where expected what Im doing wrong here?
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
String qry = "select pin,emp_acct_no,attn_name,address_line1,address_line2,po_box_no,city,state,zip,country_code,email" + "FROM w_employer WHERE pin='" + pinnum + " 'AND emp_acct_no="+checkaccountNumber;
There's no space between "country_code,email" and "FROM". They get concatenated and the SQL compiler can't find the FROM keyword.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Mary Wallace
Ranch Hand
Joined: Aug 25, 2003
Posts: 138
|
|
I changed like this and it worked i want to change that as a prepared statement like this: but it gave me an error "DB Connection Error(validate pin frm db): java.sql.SQLException: ORA-00923: FROM keyword not found where expected" what i have to do here? thanks in advance
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
Did you read Joe's response?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Mary Wallace
Ranch Hand
Joined: Aug 25, 2003
Posts: 138
|
|
|
The problem was not bcoz of the space as Joe suggested.When i rewrote the sql it worked.
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8264
|
|
|
Your String query has a space before FROM but the String literal in your prepared statement doesn't have the space. Attention to detail!
|
 |
Mary Wallace
Ranch Hand
Joined: Aug 25, 2003
Posts: 138
|
|
thanks
|
 |
 |
|
|
subject: help in sql
|
|
|