1

executeUpdate return 1 but values are not inserted into the table. 'CR_SAVEHBCRPERFORMA ' is the procedure to insert values. output parameter return 1 after execute else 0, here return 0..(some code missed bcoz too length )

    Connection con = null;
    CallableStatement cstmt1 = null;
    DataSource ds = null;
    ResultSet rs = null;
    try {
       
        String REGNO = request.getParameter("regNo");
        String CENTERNAME = request.getParameter("center");
        String DIAGNOSISDATE = request.getParameter("firstDiag");
        RccDataSources rccDS = new RccDataSources();
        ds = rccDS.getOncoLiveDS();
        con = ds.getConnection();
        cstmt1 = con.prepareCall("{CALL CR_SAVEHBCRPERFORMA(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
        cstmt1.setString(1, REGNO);
        cstmt1.setString(2, CENTERNAME);
        cstmt1.setString(3, DIAGNOSISDATE);
        cstmt1.setString(4, SOURCEREG);
        cstmt1.setString(5, SOURCEREF);
        cstmt1.setString(6, LABNO); 
        cstmt1.setString(7, FIRSTSEENDATE);
        cstmt1.setString(8, EDUCATION);
        cstmt1.setString(28, TREATMENTRITYPE);
        cstmt1.setString(29, STATUSFOLLOWUP);
        cstmt1.setString(30, DISEASESTATUS);
        cstmt1.setString(31, REMARK);
        cstmt1.registerOutParameter(32, Types.INTEGER);
        cstmt1.executeUpdate();
        int x = cstmt1.getInt(32);
  
    } 
}

}

  • Maybe you didn't commit? See [this](https://stackoverflow.com/questions/40289951/executeupdate-sql-statement-in-java-not-working). – MaS Aug 28 '20 at 06:23

1 Answers1

0

Use

cstmt1.execute();

For Example

        stmt.setString(1, doc_number);
        stmt.setString(2, doc_type);
        stmt.setString(3, line_number);
        stmt.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR);
        
        stmt.execute();
        cursor = stmt.getCursor(4);
WaqarAli
  • 173
  • 10
  • ERROR: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'CR_SAVEHBCRPERFORMA' ORA-06550: line 1, column 7: PL/SQL: Statement ignored – Reshma R Gopal Aug 28 '20 at 07:01
  • That error usually comes when you try to send wrong parameter value number instead of varchar. – WaqarAli Aug 28 '20 at 07:38