Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pl sql的java executeUpdate始终返回1,即使该行没有';不存在_Java_Jdbc_Plsql - Fatal编程技术网

pl sql的java executeUpdate始终返回1,即使该行没有';不存在

pl sql的java executeUpdate始终返回1,即使该行没有';不存在,java,jdbc,plsql,Java,Jdbc,Plsql,我有下面的java代码,其中executeUpdate()的输出被捕获为int,并且值始终为1。对于输入值,DB中没有行,但仍返回1。为什么?我错过什么了吗 /*******************Java code *************/ /**** Code to get connection above ***/ CallableStatement oraCallStmt = null; try { oraCallStmt =

我有下面的java代码,其中executeUpdate()的输出被捕获为int,并且值始终为1。对于输入值,DB中没有行,但仍返回1。为什么?我错过什么了吗

    /*******************Java code *************/


    /**** Code to get connection above ***/
    CallableStatement oraCallStmt   = null;

    try {
        oraCallStmt =   connection.prepareCall(
                "{ call XXXXX.UPDATEMEMBERNUMBER(?,?)}"
            );
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return ;
    }
        try {
            //Reading a comma delimited file to get two column values
            //One into the where clause and one into the update clause
            while ((str = in.readLine()) != null) {

                String[] ar = str.split(",");

                oraCallStmt.setString(1,ar[0].trim());
                oraCallStmt.setString(2,ar[1].trim());

                int output = oraCallStmt.executeUpdate();

                //The output returns 1 always even if the row doesn't exist
                System.out.println(str +'-'+output);

                //Writing the result to another file
                bw.write(str +'-'+output);
                bw.newLine() ;
                bw.flush();
            }
            bw.close();
        }catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }



    /************pl-sql package*******************/

    PROCEDURE UpdateMemberNumber(CUSTID_INP IN VARCHAR,
                         MEM_NUM_INP IN VARCHAR) IS
    BEGIN
       UPDATE GENESIS.CUSTOMER
       SET MEMBER_NUMBER = MEM_NUM_INP
       WHERE CUSTOMER_ID = CUSTID_INP ;

    END UpdateMemberNumber ;

这是一个好问题。但我认为executeUpdate()只为DML语句返回受影响的行数。程序更加复杂。设想这样的过程可以调用其他几个过程,这些过程也可以更新或删除行。在这种情况下,executeUpdate()将返回什么?所以我认为对于过程,它只返回一个常量。我的要求是使用pl sql过程来进行更新。有没有其他方法可以知道某一行的更新是否失败?您可以在plsql代码中检测到这种情况并返回in out参数try getUpdateCount()方法?根据,当storedProc不返回结果时,首选executeUpdate。我不确定这篇文章的有效性。它是关于EXCEQUERY和execute方法的。你可以试试。看看我的博客,有一个没有参数的过程。您可以将其用作模板。