gpt4 book ai didi

java - ORA-00911 : invalid character error using a PreparedStatement

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:40 24 4
gpt4 key购买 nike

我正在尝试使用 Prepared Stmt 在 where 子句中传递订单号列表。我收到的错误是 Invalid character 。使用下面的代码

        List<String> ordernolist = Arrays.asList(orderno.split(","));


String sql = "select * from ORDER_"+Market+".MARC_ORD_UN_STS_T s,ORDER_"+Market+".MARC_ORD_LN_T l, "
+ "ORDER_"+Market+".MARC_ORD_T o ,ORDER_"+Market+".ORD_RLS_REL_T ort,ORDER_"+Market+".RLS_T rt,ORDER_"+Market+".RLS_LN_T rn "
+ "where RT.RLS_KEY=RN.RLS_KEY and O.MARC_ORD_KEY=L.MARC_ORD_KEY and L.MARC_ORD_LN_KEY=S.MARC_ORD_LN_KEY and "
+ "O.ORD_NO=ORT.ORD_NBR and ORT.CRM_ORD_NBR=RT.CRM_ORD_NBR and "
//+ "S.MARC_ORD_STS_CD='500' and "
+ "RN.LN_QTY>0 and RN.ORIG_ORD_LN_NBR=L.ORD_LN_NBR and s.sts_qty>0 "
+ "and O.ORD_NO in (";
for( String id : ordernolist ){
sql += "?,";
}
sql = sql.substring( 0, sql.length()-1 ) + ");";
//System.out.println(sql);


PreparedStatement preparedStatement = OmsConn.prepareStatement(sql);

for( int ono = 0; ono < ordernolist.size(); ono++ ){
preparedStatement.setString(ono+1, ordernolist.get(ono));
}

错误:java.sql.SQLException:ORA-00911:无效字符

谁能帮忙修一下

最佳答案

无效字符是 sql 末尾的分号。

改变这一行:

sql = sql.substring( 0, sql.length()-1  ) + ");";

sql = sql.substring( 0, sql.length()-1  ) + ")";

关于java - ORA-00911 : invalid character error using a PreparedStatement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27169745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com