wood burning stoves 2.0*
The moose likes JDBC and the fly likes Problem with Oracle Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with Oracle Query" Watch "Problem with Oracle Query" New topic
Author

Problem with Oracle Query

ec hurley
Greenhorn

Joined: Mar 11, 2005
Posts: 21
Can anyone help? My SQL is giving me an error ORA-00909: invalid number of arguments.

private static final String CUM =
"select SUMMARY_MONTH" +
", SUM(INQ_TOTAL)" +
", SUM(INQ_INVALID)" +
", SUM(RESP_NULL)" +
", SUM(RESP_CACHE)" +
", SUM(RESP_INQ_MGR " +
", SUM(RESP_ACTIVE)" +
", SUM(RESP_INACTIVE)" +
", SUM(RESP_UNDETERMINED)" +
", SUM(RESP_INVALID270)" +
", SUM(RESP_AAA_TOTAL)" +
", SUM(RESP_BADRESP)" +
" from SITE_MONTHLY_SUM" +
" where SUMMARY_MONTH >= TO_DATE('?', 'yyyy/mm/dd')" +
" and SUMMARY_MONTH <= TO_DATE('?', 'yyyy/mm/dd')" +
" GROUP by SUMMARY_MONTH";

public void getCum( java.sql.Date start_date, java.sql.Date end_date)
throws SQLException{
log.info("UserDAOOracleImpl class getCum method");
cumBean cb = (cumBean) sc.getAttribute("cumbean");
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
con = getConnection();
log.info("Get Connection successful " + con.toString());
ps = con.prepareStatement(CUM);
ps.setDate(1, start_date);
ps.setDate(2, end_date);
log.info("QUERY = " + CUM);
rs = ps.executeQuery();
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by ec hurley:
" where SUMMARY_MONTH >= TO_DATE('?', 'yyyy/mm/dd')" +
" and SUMMARY_MONTH <= TO_DATE('?', 'yyyy/mm/dd')" +




Remove the single quotes for place holder (?)

Shailesh
[ December 10, 2008: Message edited by: Shailesh Chandra ]

Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
ec hurley
Greenhorn

Joined: Mar 11, 2005
Posts: 21
Removing the quotes did not solve the problem.
ec hurley
Greenhorn

Joined: Mar 11, 2005
Posts: 21
I found the error. Missing ")" after INQ_MGR.
 
 
subject: Problem with Oracle Query