SQL语句:
SELECT * FROM (
SELECT rownum rid ,condata.*
FROM (
SELECT max(ODP_CTT.NUM_CTT_ID) conid ,ODP_CTT.VC2_BUS_CTT_ID AS ecpid ,ODP_CTT.vc2_title AS title ,ODP_CTT.vc2_briefly AS description ,EC_ECP_INFO.vc2_price AS opri ,ec_ecp_info.vc2_discount AS npri ,max(ODP_CTT.vc2_dft_icon) AS iurl ,to_char(ec_ecp_info.dat_update, 'yyyymmddhhmiss') AS upt
FROM ODP_CTT ,ec_ecp_info
where odp_ctt.num_status = 3
and (
lower(vc2_title) LIKE lower('%?%')
or lower(ODP_CTT.vc2_briefly) LIKE lower('%?%')
)
AND ec_ecp_info.vc2_ecp_id = odp_ctt.VC2_BUS_CTT_ID
GROUP BY ODP_CTT.VC2_BUS_CTT_ID ,ODP_CTT.vc2_title ,ODP_CTT.vc2_briefly ,EC_ECP_INFO.vc2_price ,ec_ecp_info.vc2_discount ,to_char(ec_ecp_info.dat_update, 'yyyymmddhhmiss')
) condata
order by to_number (upt) desc
)
我设置:
stmt.setString(1, keyword_f);
stmt.setString(2, keyword_f);
我得到了:
java.sql.SQLException:oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)中的列索引无效
答案 0 :(得分:0)
lower(vc2_title) LIKE lower('%?%')
or lower(ODP_CTT.vc2_briefly) LIKE lower('%?%')
我认为你不能将?
放在字符串中。你可能需要这样做:
lower(vc2_title) LIKE lower(?)
or lower(ODP_CTT.vc2_briefly) LIKE lower(?)
然后在Java中:
stmt.setString(1, "%" + keyword_f + "%");
stmt.setString(2, "%" + keyword_f + "%");