0

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)

4

1 回答 1

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 + "%");
于 2012-09-20T22:41:51.897 回答