简体   繁体   English

使用Java调用PL / SQL函数时,类型或参数数量错误。 PLS-00306错误

[英]Wrong type or number of parameters when calling a PL/SQL function using Java. PLS-00306 error

try{
        Statement stmt = conn.createStatement();
            stmt.execute("CREATE OR REPLACE FUNCTION log(p_user IN VARCHAR2, p_password IN VARCHAR2, p_name IN VARCHAR2 ) "
                    + "RETURN number "
                    + "IS "
                    + "flag login%ROWTYPE; "
                    + "temp number; "
                    + "BEGIN "
                    + "select username into flag "
                    + "from login "
                    + "where username=p_user and password=p_password and name=p_name; "
                    + "IF (sql%found) THEN temp:= 1; "
                    + "ELSE temp:= 0; "
                    + "END IF; "
                    + "return temp; "
                    + "END; ");

            stmt.close();

            String value = Combo_Name.getSelectedItem().toString();

            String sql= "begin "
                    + "?:=log(?,?,?); "
                    + "end; ";

            CallableStatement cstmt = conn.prepareCall (sql);

            cstmt.registerOutParameter (1, OracleTypes.NUMBER);
            cstmt.setString(2, user_id.getText());
            cstmt.setString (3, password.getText()); 
            cstmt.setString(4, value);

            cstmt.execute();

            int check =cstmt.getInt(1);

             if(check==1)
            {
                JOptionPane.showMessageDialog(null, "Login Successful");
            }
            else
            {
                JOptionPane.showMessageDialog(null, "Invalid Username or Password");
            }

    }catch(Exception e){
        JOptionPane.showMessageDialog(null, e);
    }
}        

A pls-00306 error is shown when I am calling the function. 调用函数时显示pls-00306错误。 Every time it shows wrong type or numbers of parameters. 每次显示错误的类型或参数数量。 Please help me to resolve the errors. 请帮助我解决错误。 The variable value is used to take input from the combo box. 变量值用于从组合框中获取输入。

You are clashing with a built-in function LOG(n2,n1) that returns the logarithm , base n2 , of n1 . 您使用的是内置的功能冲突LOG(n2,n1)返回对数 ,基地n2的, n1

Use another name. 使用其他名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用带有布尔 IN 参数的 CallableStatement 在 Java 中调用 Oracle PL/SQL 过程会产生 PLS-00306 oracle 错误: - Calling an Oracle PL/SQL procedure in Java using a CallableStatement with a boolean IN parameter gives an PLS-00306 oracle error: 休眠PLS-00306错误 - hibernate PLS-00306 error PLS-00306:Java中对GET_NEW_EVENTS的调用中参数的数量或类型错误 - PLS-00306: wrong number or types of arguments in call to GET_NEW_EVENTS in Java MyBatis Oracle呼叫PLS-00306:呼叫错误的参数数量或类型错误 - MyBatis Oracle Call PLS-00306: wrong number or types of arguments in call Error 当 Hibernate 看起来正确时,为什么我会收到 PLS-00306“调用中的 arguments 的数量或类型错误”? - Why am I getting PLS-00306 “wrong number or types of arguments in call” when the Hibernate looks correct? 引起:java.sql.SQLException:ORA-06550:第 1 行,第 7 列:PLS-00306:ZDBC11CAA5BDA99F77E6FB4DABD_SPE_FA 7 调用中的 ZDBC11CAA5BDA99F77E6FB4DABD8SPE_7 的错误编号或类型 - Caused by: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'PR_SP_FAHMI' ORA-06550:第1行,第7列:PLS-00306:错误的数量或调用中的参数类型 - ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call 具有命名绑定的 CallableStatement 导致 PLS-00306:错误的参数数量或类型 - CallableStatement with Named binding leads to PLS-00306: wrong number or types of arguments 在Java中调用oracle PL / SQL函数-无效的列类型错误 - calling oracle PL/SQL function in java - Invalid column type error 使用CLOB和VARCHAR2参数从PL / SQL调用Java函数 - Calling a Java function from PL/SQL with CLOB and VARCHAR2 Parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM