| Author |
Invalid column name error
|
Lalitha Vydyula
Ranch Hand
Joined: Jul 20, 2005
Posts: 69
|
|
Hi all, trying select max(approval_level).. gives java.sql.SQLException: Invalid column name I have a query like this select max(approval_level) as maxlevel from fam_quote_header_approval , fam_quote_line_approval where fam_quote_header_approval.header_approval_id = fam_quote_line_approval.header_approval_id and quote_number = 5443 and status = 'Approved' when I execute the query from SQL prompt its executing fine. but when I execute it from the jdbc it erroring out try { approvedLvlConn = (OracleConnection)getConnection(); approvedOpstmt = (OraclePreparedStatement) approvedLvlConn.prepareStatement(approvedLevelStr.toString()); approvedSet = approvedOpstmt.executeQuery(); if(approvedSet.next()) maxLevel = approvedSet.getInt(approvedSet.getInt("maxlevel")); } Can anyone help. Thanks.
|
 |
Scott Selikoff
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3652
|
|
Just a thought, but have you tried using table aliases throughout your query such as: I just guessed which aliases some of the columns belong with. Often times its because of a mismatch or a confusion, using table aliases avoids it.
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
Dimit Chadha
Greenhorn
Joined: Jul 05, 2006
Posts: 2
|
|
HI It will be better practice to use column numbers instead of column names. This is a tricky solution but it will reduce the error of misspelled column names.
|
 |
 |
|
|
subject: Invalid column name error
|
|
|