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


i trying pass list of order numbers in clause using prepared stmt. getting error invalid character . using below code

        list<string> ordernolist = arrays.aslist(orderno.split(","));           string sql = "select * 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 , o.marc_ord_key=l.marc_ord_key , l.marc_ord_ln_key=s.marc_ord_ln_key , "                 + "o.ord_no=ort.ord_nbr , ort.crm_ord_nbr=rt.crm_ord_nbr , "                 //+ "s.marc_ord_sts_cd='500' , "                 + "rn.ln_qty>0 , rn.orig_ord_ln_nbr=l.ord_ln_nbr , 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));             } 

error: java.sql.sqlexception: ora-00911: invalid character

could in fixing it

the invalid character semi colon @ end of sql.

change line:

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

to

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

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -